diff --git a/.gitattributes b/.gitattributes index 0be242c..10dbf1b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,7 @@ /tests export-ignore .gitattributes export-ignore .gitignore export-ignore +.php_cs export-ignore .scrutinizer.yml export-ignore .travis.yml export-ignore CONTRIBUTING.md export-ignore diff --git a/.gitignore b/.gitignore index 05cf3e8..f0130d8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ /composer.lock /vendor +# PHP CS Fixer +/.php_cs.cache + # PHPUnit /phpunit.xml /build diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..8f30f15 --- /dev/null +++ b/.php_cs @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please read the LICENSE + * file that was distributed with this source code. + */ + +use PhpCsFixer\Config; +use PhpCsFixer\Finder; + +$finder = Finder::create() + ->in([ + __DIR__.'/src', + __DIR__.'/tests', + ]) + ->exclude('tests/Fixture/Resource/config'); + +return Config::create() + ->setUsingCache(true) + ->setRules([ + '@Symfony' => true, + 'binary_operator_spaces' => ['align_double_arrow' => true], + 'ordered_imports' => true, + ]) + ->setFinder($finder); diff --git a/.travis.yml b/.travis.yml index a3165f0..b5a046a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ install: - if [[ "$TRAVIS_PHP_VERSION" == "5.3.3" ]]; then composer config -g disable-tls true; fi - composer self-update - composer require --no-update symfony/form:${SYMFONY_VERSION} + - composer remove --no-update --dev friendsofphp/php-cs-fixer - if [[ "$SYMFONY_VERSION" = *dev* ]]; then sed -i "s/\"MIT\"/\"MIT\",\"minimum-stability\":\"dev\"/g" composer.json; fi - composer update --prefer-source `if [[ $COMPOSER_PREFER_LOWEST = true ]]; then echo "--prefer-lowest --prefer-stable"; fi` diff --git a/composer.json b/composer.json index 12d5ca2..9aba9e0 100644 --- a/composer.json +++ b/composer.json @@ -10,10 +10,11 @@ } ], "require": { - "php": ">=5.3.3", + "php": "^5.3|^7.0", "symfony/form": "^2.3|^3.0" }, "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0", "phpunit/phpunit": "^4.0|^5.0", "symfony/phpunit-bridge": "^2.7|^3.0" }, diff --git a/src/Builder/OrderedButtonBuilder.php b/src/Builder/OrderedButtonBuilder.php index 7978a68..80038df 100644 --- a/src/Builder/OrderedButtonBuilder.php +++ b/src/Builder/OrderedButtonBuilder.php @@ -17,13 +17,13 @@ use Symfony\Component\Form\Exception\BadMethodCallException; /** - * Ordered button builder. - * * @author GeLo */ class OrderedButtonBuilder extends ButtonBuilder implements OrderedFormConfigBuilderInterface, OrderedFormConfigInterface { - /** @var null|string|array */ + /** + * @var string|array|null + */ private $position; /** diff --git a/src/Builder/OrderedFormBuilder.php b/src/Builder/OrderedFormBuilder.php index f43cfd0..2d58a01 100644 --- a/src/Builder/OrderedFormBuilder.php +++ b/src/Builder/OrderedFormBuilder.php @@ -13,17 +13,17 @@ use Ivory\OrderedForm\Exception\OrderedConfigurationException; use Ivory\OrderedForm\OrderedFormConfigInterface; -use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\Exception\BadMethodCallException; +use Symfony\Component\Form\FormBuilder; /** - * Ordered form builder. - * * @author GeLo */ class OrderedFormBuilder extends FormBuilder implements OrderedFormConfigBuilderInterface, OrderedFormConfigInterface { - /** @var null|string|array */ + /** + * @var string|array|null + */ private $position; /** diff --git a/src/Builder/OrderedFormConfigBuilderInterface.php b/src/Builder/OrderedFormConfigBuilderInterface.php index 41dff80..9e1e7a5 100644 --- a/src/Builder/OrderedFormConfigBuilderInterface.php +++ b/src/Builder/OrderedFormConfigBuilderInterface.php @@ -11,6 +11,7 @@ namespace Ivory\OrderedForm\Builder; +use Symfony\Component\Form\Exception\InvalidConfigurationException; use Symfony\Component\Form\FormConfigBuilderInterface; /** @@ -21,36 +22,11 @@ interface OrderedFormConfigBuilderInterface extends FormConfigBuilderInterface { /** - * Sets the form position. + * @param string|array|null $position * - * * The position can be `null` to reflect the original forms order. + * @throws InvalidConfigurationException * - * * The position can be `first` to place this form at the first position. - * If many forms are defined as `first`, the original order between these forms is maintained. - * Warning, `first` does not mean "very first" if there are many forms which are defined as `first` - * or if you set up an other form `before` this form. - * - * * The position can be `last` to place this form at the last position. - * If many forms are defined as `last`, the original order between these forms is maintained. - * Warning, `last` does not mean "very last" if there are many forms which are defined as `last` - * or if you set up an other form `after` this form. - * - * * The position can be `array('before' => 'form_name')` to place this form before the `form_name` form. - * If many forms defines the same `before` form, the original order between these forms is maintained. - * Warning, `before` does not mean "just before" if there are many forms which defined the same `before` form. - * - * * The position can be `array('after' => 'form_name')` to place this form after the `form_name` form. - * If many forms defines the same after form, the original order between these forms is maintained. - * Warning, `after` does not mean "just after" if there are many forms which defined the same `after` form. - * - * You can combine the `after` & `before` options together or with `first` and/or `last` to achieve - * more complex use cases. - * - * @param null|string|array $position The form position. - * - * @throws \Symfony\Component\Form\Exception\InvalidConfigurationException If the position is not valid. - * - * @return \Ivory\OrderedForm\OrderedFormConfigBuilderInterface The ordered form configuration builder. + * @return OrderedFormConfigBuilderInterface */ public function setPosition($position); } diff --git a/src/Builder/OrderedSubmitButtonBuilder.php b/src/Builder/OrderedSubmitButtonBuilder.php index a0f8e71..a5929e0 100644 --- a/src/Builder/OrderedSubmitButtonBuilder.php +++ b/src/Builder/OrderedSubmitButtonBuilder.php @@ -13,17 +13,17 @@ use Ivory\OrderedForm\Exception\OrderedConfigurationException; use Ivory\OrderedForm\OrderedFormConfigInterface; -use Symfony\Component\Form\SubmitButtonBuilder; use Symfony\Component\Form\Exception\BadMethodCallException; +use Symfony\Component\Form\SubmitButtonBuilder; /** - * Ordered submit button builder. - * * @author GeLo */ class OrderedSubmitButtonBuilder extends SubmitButtonBuilder implements OrderedFormConfigBuilderInterface, OrderedFormConfigInterface { - /** @var null|string|array */ + /** + * @var string|array|null + */ private $position; /** diff --git a/src/Exception/OrderedConfigurationException.php b/src/Exception/OrderedConfigurationException.php index 09ef2ea..a813821 100644 --- a/src/Exception/OrderedConfigurationException.php +++ b/src/Exception/OrderedConfigurationException.php @@ -14,19 +14,15 @@ use Symfony\Component\Form\Exception\InvalidConfigurationException; /** - * Ordered configuration exception. - * * @author GeLo */ class OrderedConfigurationException extends InvalidConfigurationException { /** - * Creates a "CIRCULAR DIFFERED" exception. - * - * @param array $stack The circular stack. - * @param string $position The position (before|after). + * @param array $stack + * @param string $position * - * @return \Ivory\OrderedForm\Exception\OrderedConfigurationException The "CIRCULAR DIFFERED" exception. + * @return OrderedConfigurationException */ public static function createCircularDiffered(array $stack, $position) { @@ -40,13 +36,11 @@ public static function createCircularDiffered(array $stack, $position) } /** - * Creates an "INVALID DIFFERED" exception. - * - * @param string $name The form name. - * @param string $position The position (before|after). - * @param string $differed The differed form name. + * @param string $name + * @param string $position + * @param string $differed * - * @return \Ivory\OrderedForm\Exception\OrderedConfigurationException The "INVALID DIFFERED" exception. + * @return OrderedConfigurationException */ public static function createInvalidDiffered($name, $position, $differed) { @@ -62,13 +56,10 @@ public static function createInvalidDiffered($name, $position, $differed) } /** - * Creates an "INVALID STRING POSITION" exception. - * - * @param string $name The form name. - * @param string $position The invalid string position. - * + * @param string $name + * @param string $position * - * @return \Ivory\OrderedForm\Exception\OrderedConfigurationException The "INVALID STRING POSITION" exception. + * @return OrderedConfigurationException */ public static function createInvalidStringPosition($name, $position) { @@ -80,12 +71,10 @@ public static function createInvalidStringPosition($name, $position) } /** - * Creates an "INVALID ARRAY CONFIGURATION" exception. + * @param string $name + * @param array $position * - * @param string $name The form name. - * @param array $position The invalid array position. - * - * @return \Ivory\OrderedForm\Exception\OrderedConfigurationException The "INVALID ARRAY CONFIGURATION" exception. + * @return OrderedConfigurationException */ public static function createInvalidArrayPosition($name, array $position) { @@ -97,12 +86,10 @@ public static function createInvalidArrayPosition($name, array $position) } /** - * Creates a "SYMETRIC DIFFERED" exception. - * - * @param string $name The form name. - * @param string $symetric The symectric form name. + * @param string $name + * @param string $symetric * - * @return \Ivory\OrderedForm\Exception\OrderedConfigurationException The "SYMETRIC DIFFERED" exception. + * @return OrderedConfigurationException */ public static function createSymetricDiffered($name, $symetric) { @@ -114,12 +101,10 @@ public static function createSymetricDiffered($name, $symetric) } /** - * Decorates values with the decorator. + * @param array $values + * @param string $decorator * - * @param array $values The values. - * @param string $decorator The decorator. - * - * @return array The decorated values. + * @return array */ private static function decorateValues(array $values, $decorator = '"') { @@ -133,12 +118,10 @@ private static function decorateValues(array $values, $decorator = '"') } /** - * Decorates a value with the decorator. - * - * @param string $value The value. - * @param string $decorator The decorator. + * @param string $value + * @param string $decorator * - * @return string The decorated value. + * @return string */ private static function decorateValue($value, $decorator = '"') { diff --git a/src/Extension/AbstractOrderedExtension.php b/src/Extension/AbstractOrderedExtension.php index 1f0ff4d..76a8aa9 100644 --- a/src/Extension/AbstractOrderedExtension.php +++ b/src/Extension/AbstractOrderedExtension.php @@ -17,8 +17,6 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** - * Abstract ordered extension. - * * @author GeLo */ abstract class AbstractOrderedExtension extends AbstractTypeExtension @@ -32,7 +30,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) } /** - * @param OptionsResolver $resolver + * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { diff --git a/src/Extension/OrderedButtonExtension.php b/src/Extension/OrderedButtonExtension.php index 3ecc023..d885f10 100644 --- a/src/Extension/OrderedButtonExtension.php +++ b/src/Extension/OrderedButtonExtension.php @@ -12,16 +12,14 @@ namespace Ivory\OrderedForm\Extension; /** - * Ordered form button extension. - * - * @author tweini * @author GeLo + * @author tweini */ class OrderedButtonExtension extends AbstractOrderedExtension { /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function getExtendedType() { return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') diff --git a/src/Extension/OrderedExtension.php b/src/Extension/OrderedExtension.php index e8628c1..fa27284 100644 --- a/src/Extension/OrderedExtension.php +++ b/src/Extension/OrderedExtension.php @@ -14,8 +14,6 @@ use Symfony\Component\Form\AbstractExtension; /** - * Ordered extension. - * * @author GeLo */ class OrderedExtension extends AbstractExtension diff --git a/src/Extension/OrderedFormExtension.php b/src/Extension/OrderedFormExtension.php index b158d7b..e58776f 100644 --- a/src/Extension/OrderedFormExtension.php +++ b/src/Extension/OrderedFormExtension.php @@ -12,8 +12,6 @@ namespace Ivory\OrderedForm\Extension; /** - * Ordered form extension. - * * @author GeLo */ class OrderedFormExtension extends AbstractOrderedExtension diff --git a/src/OrderedFormConfigInterface.php b/src/OrderedFormConfigInterface.php index 29df2f3..2847967 100644 --- a/src/OrderedFormConfigInterface.php +++ b/src/OrderedFormConfigInterface.php @@ -14,18 +14,12 @@ use Symfony\Component\Form\FormConfigInterface; /** - * Ordered form configuration. - * * @author GeLo */ interface OrderedFormConfigInterface extends FormConfigInterface { /** - * Gets the form position. - * - * @see \Ivory\OrderedForm\OrderedFormConfigBuilderInterface::setPosition - * - * @return null|string|array The form position. + * @return string|array|null */ public function getPosition(); } diff --git a/src/OrderedResolvedFormType.php b/src/OrderedResolvedFormType.php index 951d932..0d59831 100644 --- a/src/OrderedResolvedFormType.php +++ b/src/OrderedResolvedFormType.php @@ -26,17 +26,20 @@ use Symfony\Component\Form\SubmitButtonTypeInterface; /** - * Ordered resolved form type. - * * @author GeLo */ class OrderedResolvedFormType extends ResolvedFormType { - /** @var \Ivory\OrderedForm\Orderer\FormOrdererInterface */ + /** + * @var FormOrdererInterface + */ private $orderer; /** - * {@inheritdoc} + * @param FormOrdererInterface $orderer + * @param FormTypeInterface $innerType + * @param array $typeExtensions + * @param ResolvedFormTypeInterface|null $parent */ public function __construct( FormOrdererInterface $orderer, diff --git a/src/OrderedResolvedFormTypeFactory.php b/src/OrderedResolvedFormTypeFactory.php index 28708a4..aecf4e2 100644 --- a/src/OrderedResolvedFormTypeFactory.php +++ b/src/OrderedResolvedFormTypeFactory.php @@ -18,19 +18,17 @@ use Symfony\Component\Form\ResolvedFormTypeInterface; /** - * Ordered resolved form type factory. - * * @author GeLo */ class OrderedResolvedFormTypeFactory extends ResolvedFormTypeFactory { - /** @var \Ivory\OrderedForm\Orderer\FormOrdererInterface */ + /** + * @var FormOrdererInterface + */ private $orderer; /** - * Creates an orderer resolved form type factory. - * - * @param \Ivory\OrderedForm\Orderer\FormOrdererInterface|null $orderer The form orderer. + * @param FormOrdererInterface|null $orderer */ public function __construct(FormOrdererInterface $orderer = null) { diff --git a/src/Orderer/FormOrderer.php b/src/Orderer/FormOrderer.php index e38699b..9b0f024 100644 --- a/src/Orderer/FormOrderer.php +++ b/src/Orderer/FormOrderer.php @@ -15,25 +15,33 @@ use Symfony\Component\Form\FormInterface; /** - * Form orderer. - * * @author GeLo */ class FormOrderer implements FormOrdererInterface { - /** @var array */ + /** + * @var array + */ private $weights; - /** @var array */ + /** + * @var array + */ private $differed; - /** @var integer */ + /** + * @var int + */ private $firstWeight; - /** @var integer */ + /** + * @var int + */ private $currentWeight; - /** @var integer */ + /** + * @var int + */ private $lastWeight; /** @@ -61,9 +69,7 @@ public function order(FormInterface $form) } /** - * Processes an an empty position. - * - * @param \Symfony\Component\Form\FormInterface $form The form. + * @param FormInterface $form */ private function processEmptyPosition(FormInterface $form) { @@ -71,10 +77,8 @@ private function processEmptyPosition(FormInterface $form) } /** - * Processes a string position. - * - * @param \Symfony\Component\Form\FormInterface $form The form. - * @param string $position The position. + * @param FormInterface $form + * @param string $position */ private function processStringPosition(FormInterface $form, $position) { @@ -86,10 +90,8 @@ private function processStringPosition(FormInterface $form, $position) } /** - * Processes an array position. - * - * @param \Symfony\Component\Form\FormInterface $form The form. - * @param array $position The position. + * @param FormInterface $form + * @param array $position */ private function processArrayPosition(FormInterface $form, array $position) { @@ -103,9 +105,7 @@ private function processArrayPosition(FormInterface $form, array $position) } /** - * Processes a first position. - * - * @param \Symfony\Component\Form\FormInterface $form The form. + * @param FormInterface $form */ private function processFirst(FormInterface $form) { @@ -113,9 +113,7 @@ private function processFirst(FormInterface $form) } /** - * Processes a last position. - * - * @param \Symfony\Component\Form\FormInterface $form The form. + * @param FormInterface $form */ private function processLast(FormInterface $form) { @@ -123,10 +121,8 @@ private function processLast(FormInterface $form) } /** - * Processes a before position. - * - * @param \Symfony\Component\Form\FormInterface $form The form. - * @param string $before The before form name. + * @param FormInterface $form + * @param string $before */ private function processBefore(FormInterface $form, $before) { @@ -138,10 +134,8 @@ private function processBefore(FormInterface $form, $before) } /** - * Processes an after position. - * - * @param \Symfony\Component\Form\FormInterface $form The form. - * @param string $after The after form name. + * @param FormInterface $form + * @param string $after */ private function processAfter(FormInterface $form, $after) { @@ -153,37 +147,33 @@ private function processAfter(FormInterface $form, $after) } /** - * Processes a weight. - * - * @param \Symfony\Component\Form\FormInterface $form The form. - * @param integer $weight The weight. + * @param FormInterface $form + * @param int $weight */ private function processWeight(FormInterface $form, $weight) { foreach ($this->weights as &$weightRef) { if ($weightRef >= $weight) { - $weightRef++; + ++$weightRef; } } if ($this->currentWeight >= $weight) { - $this->currentWeight++; + ++$this->currentWeight; } - $this->lastWeight++; + ++$this->lastWeight; $this->weights[$form->getName()] = $weight; $this->finishWeight($form, $weight); } /** - * Finishes the weight processing. + * @param FormInterface $form + * @param int $weight + * @param string $position * - * @param \Symfony\Component\Form\FormInterface $form The form. - * @param integer $weight The weight. - * @param string $position The position (null|before|after). - * - * @return integer The new weight. + * @return int */ private function finishWeight(FormInterface $form, $weight, $position = null) { @@ -209,13 +199,11 @@ private function finishWeight(FormInterface $form, $weight, $position = null) } /** - * Processes differed. - * - * @param \Symfony\Component\Form\FormInterface $form The form. - * @param string $differed The differed form name. - * @param string $position The position (before|after). + * @param FormInterface $form + * @param string $differed + * @param string $position * - * @throws \Ivory\OrderedForm\Exception\OrderedConfigurationException If the differed form does not exist. + * @throws OrderedConfigurationException */ private function processDiffered(FormInterface $form, $differed, $position) { @@ -232,13 +220,11 @@ private function processDiffered(FormInterface $form, $differed, $position) } /** - * Detects circular before/after differed. - * - * @param string $name The form name. - * @param string $position The position (before|after) - * @param array $stack The circular stack. + * @param string $name + * @param string $position + * @param array $stack * - * @throws \Ivory\OrderedForm\Exception\CircularConfigurationException If there is a circular before/after differed. + * @throws OrderedConfigurationException */ private function detectCircularDiffered($name, $position, array $stack = array()) { @@ -260,13 +246,11 @@ private function detectCircularDiffered($name, $position, array $stack = array() } /** - * Detects symmetric before/after differed. + * @param string $name + * @param string $differed + * @param string $position * - * @param string $name The form name. - * @param string $differed The differed form name. - * @param string $position The position (before|after). - * - * @throws \Ivory\OrderedForm\Exception\OrderedConfigurationException If there is a symetric before/after differed. + * @throws OrderedConfigurationException */ private function detectedSymmetricDiffered($name, $differed, $position) { @@ -281,9 +265,6 @@ private function detectedSymmetricDiffered($name, $differed, $position) } } - /** - * Resets the orderer. - */ private function reset() { $this->weights = array(); diff --git a/src/Orderer/FormOrdererInterface.php b/src/Orderer/FormOrdererInterface.php index 98f6dd1..28a5a1e 100644 --- a/src/Orderer/FormOrdererInterface.php +++ b/src/Orderer/FormOrdererInterface.php @@ -14,18 +14,14 @@ use Symfony\Component\Form\FormInterface; /** - * Form orderer. - * * @author GeLo */ interface FormOrdererInterface { /** - * Orders the form. - * - * @param \Symfony\Component\Form\FormInterface $form The form. + * @param FormInterface $form * - * @return array The ordered form child names. + * @return array */ public function order(FormInterface $form); } diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index bd3532a..0f24467 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -12,18 +12,26 @@ namespace Ivory\Tests\OrderedForm; /** - * Abstract test case. - * * @author GeLo */ abstract class AbstractTestCase extends \PHPUnit_Framework_TestCase { /** - * Creates a mock. - * - * @param string $originalClassName The original class name. + * @param string $exception + */ + public function expectException($exception) + { + if (is_callable('parent::expectException')) { + return parent::expectException($exception); + } + + return $this->setExpectedException($exception); + } + + /** + * @param string $originalClassName * - * @return \PHPUnit_Framework_MockObject_MockObject The mock. + * @return \PHPUnit_Framework_MockObject_MockObject */ protected function createMock($originalClassName) { diff --git a/tests/Builder/AbstractOrderedBuilderTest.php b/tests/Builder/AbstractOrderedBuilderTest.php index 6cad5d6..ecdfb88 100644 --- a/tests/Builder/AbstractOrderedBuilderTest.php +++ b/tests/Builder/AbstractOrderedBuilderTest.php @@ -11,16 +11,17 @@ namespace Ivory\Tests\OrderedForm\Builder; +use Ivory\OrderedForm\Builder\OrderedFormConfigBuilderInterface; use Ivory\Tests\OrderedForm\AbstractTestCase; /** - * Abstract ordered builder test. - * * @author GeLo */ abstract class AbstractOrderedBuilderTest extends AbstractTestCase { - /** @var \Ivory\OrderedForm\Builder\OrderedFormConfigBuilderInterface */ + /** + * @var OrderedFormConfigBuilderInterface + */ private $builder; /** @@ -32,17 +33,7 @@ protected function setUp() } /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->builder); - } - - /** - * Creates an ordered builder. - * - * @return \Ivory\OrderedForm\Builder\OrderedFormConfigBuilderInterface The ordered builder. + * @return OrderedFormConfigBuilderInterface */ abstract protected function createOrderedBuilder(); diff --git a/tests/Builder/OrderedButtonBuilderTest.php b/tests/Builder/OrderedButtonBuilderTest.php index c1516fa..4ee102f 100644 --- a/tests/Builder/OrderedButtonBuilderTest.php +++ b/tests/Builder/OrderedButtonBuilderTest.php @@ -14,8 +14,6 @@ use Ivory\OrderedForm\Builder\OrderedButtonBuilder; /** - * Ordered button builder test. - * * @author GeLo */ class OrderedButtonBuilderTest extends AbstractOrderedBuilderTest diff --git a/tests/Builder/OrderedFormBuilderTest.php b/tests/Builder/OrderedFormBuilderTest.php index ebd0cdc..56b8dc5 100644 --- a/tests/Builder/OrderedFormBuilderTest.php +++ b/tests/Builder/OrderedFormBuilderTest.php @@ -14,8 +14,6 @@ use Ivory\OrderedForm\Builder\OrderedFormBuilder; /** - * Ordered form builder test. - * * @author GeLo */ class OrderedFormBuilderTest extends AbstractOrderedBuilderTest diff --git a/tests/Builder/OrderedSubmitButtonBuilderTest.php b/tests/Builder/OrderedSubmitButtonBuilderTest.php index af1b82d..1214eba 100644 --- a/tests/Builder/OrderedSubmitButtonBuilderTest.php +++ b/tests/Builder/OrderedSubmitButtonBuilderTest.php @@ -14,8 +14,6 @@ use Ivory\OrderedForm\Builder\OrderedSubmitButtonBuilder; /** - * Ordered submit button builder test. - * * @author GeLo */ class OrderedSubmitButtonBuilderTest extends AbstractOrderedBuilderTest diff --git a/tests/Extension/OrderedExtensionTest.php b/tests/Extension/OrderedExtensionTest.php index 734e2a2..e5092aa 100644 --- a/tests/Extension/OrderedExtensionTest.php +++ b/tests/Extension/OrderedExtensionTest.php @@ -11,19 +11,20 @@ namespace Ivory\Tests\OrderedForm\Extension; +use Ivory\OrderedForm\Builder\OrderedFormBuilder; use Ivory\OrderedForm\Extension\OrderedExtension; use Ivory\OrderedForm\OrderedResolvedFormTypeFactory; use Ivory\Tests\OrderedForm\AbstractTestCase; use Symfony\Component\Form\Forms; /** - * Ordered extension test. - * * @author GeLo */ class OrderedExtensionTest extends AbstractTestCase { - /** @var \Ivory\OrderedForm\Builder\OrderedFormBuilder */ + /** + * @var OrderedFormBuilder + */ private $builder; /** @@ -39,29 +40,8 @@ protected function setUp() } /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->builder); - } - - /** - * Form types data provider. + * @param string $type * - * @return array The form types. - */ - public function formTypeProvider() - { - $fqcn = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix'); - - return array( - array($fqcn ? 'Symfony\Component\Form\Extension\Core\Type\TextType' : 'text'), - array($fqcn ? 'Symfony\Component\Form\Extension\Core\Type\ButtonType' : 'button'), - ); - } - - /** * @dataProvider formTypeProvider */ public function testEmptyPosition($type) @@ -72,6 +52,8 @@ public function testEmptyPosition($type) } /** + * @param string $type + * * @dataProvider formTypeProvider */ public function testStringPosition($type) @@ -82,6 +64,8 @@ public function testStringPosition($type) } /** + * @param string $type + * * @dataProvider formTypeProvider */ public function testArrayPosition($type) @@ -90,4 +74,17 @@ public function testArrayPosition($type) $this->assertSame(array('before' => 'bar'), $form->getConfig()->getPosition()); } + + /** + * @return array + */ + public function formTypeProvider() + { + $fqcn = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix'); + + return array( + array($fqcn ? 'Symfony\Component\Form\Extension\Core\Type\TextType' : 'text'), + array($fqcn ? 'Symfony\Component\Form\Extension\Core\Type\ButtonType' : 'button'), + ); + } } diff --git a/tests/Fixtures/ExtraChildrenViewExtension.php b/tests/Fixtures/ExtraChildrenViewExtension.php index cd02ea7..49af1a0 100644 --- a/tests/Fixtures/ExtraChildrenViewExtension.php +++ b/tests/Fixtures/ExtraChildrenViewExtension.php @@ -16,19 +16,17 @@ use Symfony\Component\Form\FormView; /** - * Extra view children extension. - * * @author GeLo */ class ExtraChildrenViewExtension extends AbstractTypeExtension { - /** @var array */ + /** + * @var array + */ private $names; /** - * Creates an extra view children extension. - * - * @param array $names The extra view names. + * @param array $names */ public function __construct(array $names) { diff --git a/tests/Fixtures/RemoveChildrenViewExtension.php b/tests/Fixtures/RemoveChildrenViewExtension.php index 4609e1d..098c1f3 100644 --- a/tests/Fixtures/RemoveChildrenViewExtension.php +++ b/tests/Fixtures/RemoveChildrenViewExtension.php @@ -16,19 +16,17 @@ use Symfony\Component\Form\FormView; /** - * Extra view children extension. - * * @author GeLo */ class RemoveChildrenViewExtension extends AbstractTypeExtension { - /** @var array */ + /** + * @var array + */ private $names; /** - * Creates an extra view children extension. - * - * @param array $names The extra view names. + * @param array $names */ public function __construct(array $names) { diff --git a/tests/OrderedFormFunctionnalTest.php b/tests/OrderedFormFunctionnalTest.php index 691d684..6e957ea 100644 --- a/tests/OrderedFormFunctionnalTest.php +++ b/tests/OrderedFormFunctionnalTest.php @@ -15,20 +15,24 @@ use Ivory\OrderedForm\OrderedResolvedFormTypeFactory; use Ivory\Tests\OrderedForm\Fixtures\ExtraChildrenViewExtension; use Ivory\Tests\OrderedForm\Fixtures\RemoveChildrenViewExtension; +use Symfony\Component\Form\FormFactoryBuilderInterface; +use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\Forms; use Symfony\Component\Form\FormView; /** - * Ordered form functionnal test. - * * @author GeLo */ class OrderedFormFunctionnalTest extends AbstractTestCase { - /** @var \Symfony\Component\Form\FormFactoryBuilderInterface */ + /** + * @var FormFactoryBuilderInterface + */ private $factoryBuilder; - /** @var \Symfony\Component\Form\FormFactoryInterface */ + /** + * @var FormFactoryInterface + */ private $factory; /** @@ -44,14 +48,9 @@ protected function setUp() } /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->factory); - } - - /** + * @param array $config + * @param array $expected + * * @dataProvider getValidPositions */ public function testValidPosition(array $config, array $expected) @@ -60,6 +59,9 @@ public function testValidPosition(array $config, array $expected) } /** + * @param array $config + * @param string|null $exceptionMessage + * * @dataProvider getInvalidPositions */ public function testInvalidPosition(array $config, $exceptionMessage = null) @@ -67,9 +69,9 @@ public function testInvalidPosition(array $config, $exceptionMessage = null) $exceptionName = 'Ivory\OrderedForm\Exception\OrderedConfigurationException'; if ($exceptionMessage !== null) { - $this->setExpectedException($exceptionName, $exceptionMessage); + $this->expectException($exceptionName, $exceptionMessage); } else { - $this->setExpectedException($exceptionName); + $this->expectException($exceptionName); } $this->createForm($config)->createView(); @@ -112,9 +114,7 @@ public function testRemoveChildrenView() } /** - * Gets the valid positions. - * - * @return array The valid positions. + * @return array */ public function getValidPositions() { @@ -307,7 +307,6 @@ public function getValidPositions() 'ban', 'biz' => array('before' => 'nan'), 'boz' => array('before' => 'biz', array('after' => 'pop')), - ), array('foo', 'bar', 'baz', 'bat', 'ban', 'pop', 'boz', 'biz', 'nan'), ), @@ -315,9 +314,7 @@ public function getValidPositions() } /** - * Gets the invalid positions. - * - * @return array The invalid positions. + * @return array */ public function getInvalidPositions() { @@ -386,11 +383,9 @@ public function getInvalidPositions() } /** - * Creates a form. + * @param array $config * - * @param array $config The form configuration. - * - * @return \Symfony\Component\Form\FormInterface The form. + * @return FormInterface */ private function createForm(array $config) { @@ -411,10 +406,8 @@ private function createForm(array $config) } /** - * Asserts the positions. - * - * @param \Symfony\Component\Form\FormView $view The form view. - * @param array $expected The expected positions. + * @param FormView $view + * @param array $expected */ private function assertPositions(FormView $view, array $expected) { diff --git a/tests/OrderedResolvedFormTypeFactoryTest.php b/tests/OrderedResolvedFormTypeFactoryTest.php index d7bd6cf..c0bcaf9 100644 --- a/tests/OrderedResolvedFormTypeFactoryTest.php +++ b/tests/OrderedResolvedFormTypeFactoryTest.php @@ -12,18 +12,21 @@ namespace Ivory\Tests\OrderedForm; use Ivory\OrderedForm\OrderedResolvedFormTypeFactory; +use Ivory\OrderedForm\Orderer\FormOrdererInterface; /** - * Ordered resolved form type factory test. - * * @author GeLo */ class OrderedResolvedFormTypeFactoryTest extends AbstractTestCase { - /** @var \Ivory\OrderedForm\OrderedResolvedFormTypeFactory */ + /** + * @var OrderedResolvedFormTypeFactory + */ private $resolvedFactory; - /** @var \Ivory\OrderedForm\Orderer\FormOrdererInterface */ + /** + * @var FormOrdererInterface + */ private $orderer; /** @@ -35,15 +38,6 @@ protected function setUp() $this->resolvedFactory = new OrderedResolvedFormTypeFactory($this->orderer); } - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->orderer); - unset($this->resolvedFactory); - } - public function testCreateWithOrderer() { $this->assertInstanceOf( @@ -63,9 +57,7 @@ public function testCreateWithoutOrderer() } /** - * Creates a form type. - * - * @return \Symfony\Component\Form\AbstractType The form type. + * @return AbstractType */ private function createFormType() { diff --git a/tests/OrderedResolvedFormTypeTest.php b/tests/OrderedResolvedFormTypeTest.php index 2aba697..30fd2d4 100644 --- a/tests/OrderedResolvedFormTypeTest.php +++ b/tests/OrderedResolvedFormTypeTest.php @@ -11,23 +11,30 @@ namespace Ivory\Tests\OrderedForm; -use Ivory\OrderedForm\Orderer\FormOrderer; use Ivory\OrderedForm\OrderedResolvedFormType; +use Ivory\OrderedForm\Orderer\FormOrderer; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormFactoryInterface; /** - * Ordered resolved form type test. - * * @author GeLo */ class OrderedResolvedFormTypeTest extends AbstractTestCase { - /** @var \Symfony\Component\EventDispatcher\EventDispatcher */ + /** + * @var EventDispatcherInterface + */ private $dispatcher; - /** @var \Symfony\Component\Form\FormFactoryInterface */ + /** + * @var FormFactoryInterface + */ private $factory; - /** @var \Ivory\OrderedForm\OrderedResolvedFormType */ + /** + * @var OrderedResolvedFormType + */ private $type; /** @@ -46,17 +53,6 @@ protected function setUp() ); } - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->dispatcher); - unset($this->factory); - unset($this->dataMapper); - unset($this->type); - } - public function testCreateBuilderWithButtonInnerType() { $innerType = $this->createMock('Symfony\Component\Form\Extension\Core\Type\ButtonType'); @@ -109,9 +105,7 @@ public function testCreateBuilderWithFormInnerType() } /** - * Creates a form type mock. - * - * @return \Symfony\Component\Form\AbstractType The form type mock. + * @return AbstractType */ private function createMockFormType() { @@ -119,9 +113,7 @@ private function createMockFormType() } /** - * Creates a form factory mock. - * - * @return \Symfony\Component\Form\FormFactoryInterface The form factory mock. + * @return FormFactoryInterface */ private function createMockFormFactory() {