diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5fb9633..8a55e5b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,7 +54,7 @@ We use [PSR2](http://www.php-fig.org/psr/psr-2/) as PHP coding standard. 2. [PHP Mess Detector](https://phpmd.org/) 3. PHP Copy/Paste Detector 4. PHP Dead Code Detector -5. [PHP Coding Standards Fixer](http://cs.sensiolabs.org) +5. [PHP Coding Standards Fixer](http://cs.sensiolabs.org) with --level=psr2 ## Testing and quality We use PHPUnit to test our code. Most of the project is covered with tests, so if you want your code to be merged push it with proper testing and coverage (at least 95%). To execute the tests with code coverage report: diff --git a/src/Mage/Tests/Task/TaskFactoryTest.php b/src/Mage/Tests/Task/TaskFactoryTest.php new file mode 100644 index 0000000..8972568 --- /dev/null +++ b/src/Mage/Tests/Task/TaskFactoryTest.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Mage\Tests\Task; + +use Mage\Task\TaskFactory; +use Mage\Runtime\Runtime; +use Mage\Runtime\Exception\RuntimeException; +use Exception; +use PHPUnit_Framework_TestCase as TestCase; + +class TaskFactoryTest extends TestCase +{ + public function testNonInstantiable() + { + $runtime = new Runtime(); + $factory = new TaskFactory($runtime); + + try { + $factory->get('Traversable'); + } catch (Exception $exception) { + $this->assertTrue($exception instanceof RuntimeException); + $this->assertEquals('Invalid task name "Traversable"', $exception->getMessage()); + } + } + + public function testNotExtendingAbstractTask() + { + $runtime = new Runtime(); + $factory = new TaskFactory($runtime); + + try { + $factory->get('stdClass'); + } catch (Exception $exception) { + $this->assertTrue($exception instanceof RuntimeException); + $this->assertEquals('Invalid task name "stdClass"', $exception->getMessage()); + } + } +}