From 942a2370c6a436bfe138f49ae18b4756fc710301 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sun, 1 Mar 2015 23:32:42 +0100 Subject: [PATCH 1/7] Rename CollectionType options for entries --- .../Extension/Core/Type/CollectionType.php | 45 +++++++++++--- .../Form/Tests/AbstractDivLayoutTest.php | 8 +-- .../Core/Type/CollectionTypeTest.php | 58 ++++++++++++------- .../Csrf/Type/FormTypeCsrfExtensionTest.php | 4 +- 4 files changed, 81 insertions(+), 34 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php index 508013b312..a779df6192 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php @@ -27,17 +27,17 @@ class CollectionType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { if ($options['allow_add'] && $options['prototype']) { - $prototype = $builder->create($options['prototype_name'], $options['type'], array_replace(array( + $prototype = $builder->create($options['prototype_name'], $options['entry_type'], array_replace(array( 'label' => $options['prototype_name'].'label__', - ), $options['options'], array( + ), $options['entry_options'], array( 'data' => $options['prototype_data'], ))); $builder->setAttribute('prototype', $prototype->getForm()); } $resizeListener = new ResizeFormListener( - $options['type'], - $options['options'], + $options['entry_type'], + $options['entry_options'], $options['allow_add'], $options['allow_delete'], $options['delete_empty'] @@ -76,11 +76,37 @@ class CollectionType extends AbstractType */ public function configureOptions(OptionsResolver $resolver) { - $optionsNormalizer = function (Options $options, $value) { + $entryOptionsNormalizer = function (Options $options, $value) { $value['block_name'] = 'entry'; return $value; }; + $optionsNormalizer = function (Options $options, $value) use ($entryOptionsNormalizer) { + if (null !== $value) { + @trigger_error('The form option "options" is deprecated since version 2.8 and will be removed in 3.0. Use "entry_options" instead.', E_USER_DEPRECATED); + } + + return $entryOptionsNormalizer($options, $value); + }; + $typeNormalizer = function (Options $options, $value) { + if (null !== $value) { + @trigger_error('The form option "type" is deprecated since version 2.8 and will be removed in 3.0. Use "entry_type" instead.', E_USER_DEPRECATED); + } + }; + $entryType = function (Options $options) { + if (null !== $options['type']) { + return $options['type']; + } + + return __NAMESPACE__.'\TextType'; + }; + $entryOptions = function (Options $options) { + if (1 === count($options['options']) && isset($options['block_name'])) { + return array(); + } + + return $options['options']; + }; $resolver->setDefaults(array( 'allow_add' => false, @@ -88,12 +114,17 @@ class CollectionType extends AbstractType 'prototype' => true, 'prototype_data' => null, 'prototype_name' => '__name__', - 'type' => __NAMESPACE__.'\TextType', - 'options' => array(), + // deprecated as of Symfony 2.8, to be removed in Symfony 3.0. Use entry_type instead + 'type' => null, + // deprecated as of Symfony 2.8, to be removed in Symfony 3.0. Use entry_options instead + 'options' => null, + 'entry_type' => $entryType, + 'entry_options' => $entryOptions, 'delete_empty' => false, )); $resolver->setNormalizer('options', $optionsNormalizer); + $resolver->setNormalizer('entry_options', $entryOptionsNormalizer); } /** diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php index fb7be87ead..30a8225f14 100644 --- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php @@ -284,7 +284,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testCollection() { $form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array('a', 'b'), array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -306,7 +306,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest array('title' => 'b'), ); $form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', $data, array( - 'type' => 'Symfony\Component\Form\Tests\Fixtures\AlternatingRowType', + 'entry_type' => 'Symfony\Component\Form\Tests\Fixtures\AlternatingRowType', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -324,7 +324,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testEmptyCollection() { $form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -341,7 +341,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest 'collection', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array('a', 'b'), - array('type' => 'Symfony\Component\Form\Extension\Core\Type\TextType') + array('entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType') ); $form = $this->factory->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType') diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php index 81010ae50f..cc00945f91 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -22,7 +22,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testLegacyName() { $form = $this->factory->create('collection', array( - 'type' => 'text', + 'entry_type' => 'text', )); $this->assertSame('collection', $form->getConfig()->getType()->getName()); @@ -40,8 +40,8 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testSetDataAdjustsSize() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', - 'options' => array( + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_options' => array( 'attr' => array('maxlength' => 20), ), )); @@ -69,7 +69,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testThrowsExceptionIfObjectIsNotTraversable() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); $form->setData(new \stdClass()); @@ -78,7 +78,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testNotResizedIfSubmittedWithMissingData() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $form->setData(array('foo@foo.com', 'bar@bar.com')); $form->submit(array('foo@bar.com')); @@ -92,7 +92,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_delete' => true, )); $form->setData(array('foo@foo.com', 'bar@bar.com')); @@ -107,7 +107,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_delete' => true, 'delete_empty' => true, )); @@ -124,7 +124,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testDontAddEmptyDataIfDeleteEmpty() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_add' => true, 'delete_empty' => true, )); @@ -141,7 +141,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testNoDeleteEmptyIfDeleteNotAllowed() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_delete' => false, 'delete_empty' => true, )); @@ -156,10 +156,10 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Tests\Fixtures\AuthorType', + 'entry_type' => 'Symfony\Component\Form\Tests\Fixtures\AuthorType', // If the field is not required, no new Author will be created if the // form is completely empty - 'options' => array('required' => false), + 'entry_options' => array('required' => false), 'allow_add' => true, 'delete_empty' => true, )); @@ -179,7 +179,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testNotResizedIfSubmittedWithExtraData() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $form->setData(array('foo@bar.com')); $form->submit(array('foo@foo.com', 'bar@bar.com')); @@ -192,7 +192,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_add' => true, )); $form->setData(array('foo@bar.com')); @@ -208,7 +208,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testAllowAddButNoPrototype() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', 'allow_add' => true, 'prototype' => false, )); @@ -220,7 +220,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase { $form = $this->factory ->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', 'allow_add' => true, 'prototype' => true, )) @@ -232,7 +232,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', 'prototype' => true, 'allow_add' => true, )); @@ -244,7 +244,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', 'allow_add' => true, 'prototype' => true, )); @@ -257,7 +257,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase public function testPrototypeNameOption() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', 'prototype' => true, 'allow_add' => true, )); @@ -265,7 +265,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase $this->assertSame('__name__', $form->getConfig()->getAttribute('prototype')->getName(), '__name__ is the default'); $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', 'prototype' => true, 'allow_add' => true, 'prototype_name' => '__test__', @@ -274,10 +274,26 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase $this->assertSame('__test__', $form->getConfig()->getAttribute('prototype')->getName()); } + /** + * @group legacy + */ + public function testLegacyEntryOptions() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\NumberType', + 'options' => array('attr' => array('maxlength' => '10')), + )); + + $resolvedOptions = $form->getConfig()->getOptions(); + + $this->assertEquals('Symfony\Component\Form\Extension\Core\Type\NumberType', $resolvedOptions['entry_type']); + $this->assertEquals(array('attr' => array('maxlength' => '10'), 'block_name' => 'entry'), $resolvedOptions['entry_options']); + } + public function testPrototypeDefaultLabel() { $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( - 'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', + 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', 'allow_add' => true, 'prototype' => true, 'prototype_name' => '__test__', @@ -293,7 +309,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase 'allow_add' => true, 'prototype' => true, 'prototype_data' => 'foo', - 'options' => array( + 'entry_options' => array( 'data' => 'bar', ), )); diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php index 1a1e15b53f..3a34394070 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -347,8 +347,8 @@ class FormTypeCsrfExtensionTest extends TypeTestCase { $prototypeView = $this->factory ->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( - 'type' => __CLASS__.'_ChildType', - 'options' => array( + 'entry_type' => __CLASS__.'_ChildType', + 'entry_options' => array( 'csrf_field_name' => 'csrf', ), 'prototype' => true, From 3cbfa63d051f0d5263b670184573d83ba4e6f538 Mon Sep 17 00:00:00 2001 From: Viacheslav Sychov Date: Thu, 8 Oct 2015 10:06:00 +0100 Subject: [PATCH 2/7] fix bug with set max count, by start method in progress bar --- .../Component/Console/Helper/ProgressBar.php | 38 +++++++++++++------ .../Console/Tests/Helper/ProgressBarTest.php | 21 ++++++++++ 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index 7f4b2efb8d..0c0a3fc254 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -43,6 +43,7 @@ class ProgressBar private $formatLineCount; private $messages; private $overwrite = true; + private $formatSetByUser = false; private static $formatters; private static $formats; @@ -72,7 +73,7 @@ class ProgressBar } } - $this->setFormat($this->determineBestFormat()); + $this->setFormatInternal($this->determineBestFormat()); $this->startTime = time(); } @@ -310,16 +311,8 @@ class ProgressBar */ public function setFormat($format) { - // try to use the _nomax variant if available - if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) { - $this->format = self::getFormatDefinition($format.'_nomax'); - } elseif (null !== self::getFormatDefinition($format)) { - $this->format = self::getFormatDefinition($format); - } else { - $this->format = $format; - } - - $this->formatLineCount = substr_count($this->format, "\n"); + $this->formatSetByUser = true; + $this->setFormatInternal($format); } /** @@ -345,6 +338,10 @@ class ProgressBar if (null !== $max) { $this->setMaxSteps($max); + + if (!$this->formatSetByUser) { + $this->setFormatInternal($this->determineBestFormat()); + } } $this->display(); @@ -478,6 +475,25 @@ class ProgressBar $this->overwrite(str_repeat("\n", $this->formatLineCount)); } + /** + * Sets the progress bar format. + * + * @param string $format The format + */ + private function setFormatInternal($format) + { + // try to use the _nomax variant if available + if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) { + $this->format = self::getFormatDefinition($format.'_nomax'); + } elseif (null !== self::getFormatDefinition($format)) { + $this->format = self::getFormatDefinition($format); + } else { + $this->format = $format; + } + + $this->formatLineCount = substr_count($this->format, "\n"); + } + /** * Sets the progress bar maximal steps. * diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index 78f537543e..dbcc6e2a8a 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -106,6 +106,27 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase ); } + public function testFormatWhenMaxInConstructAndInStart() + { + $bar = new ProgressBar($output = $this->getOutputStream(), 10); + $bar->start(); + $bar->advance(10); + $bar->finish(); + + rewind($output->getStream()); + $maxInConstruct = stream_get_contents($output->getStream()); + + $bar = new ProgressBar($output = $this->getOutputStream()); + $bar->start(10); + $bar->advance(10); + $bar->finish(); + + rewind($output->getStream()); + $maxInStart = stream_get_contents($output->getStream()); + + $this->assertEquals($maxInStart, $maxInConstruct); + } + public function testCustomizations() { $bar = new ProgressBar($output = $this->getOutputStream(), 10); From e651da4e6a5bbffb51ffb3e937d8e2e0ccf91c30 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 11 Oct 2015 09:29:49 +0200 Subject: [PATCH 3/7] [Console] fixed progress bar format on edge cases --- .../Component/Console/Helper/ProgressBar.php | 24 +++++++------ .../Console/Tests/Helper/ProgressBarTest.php | 34 ++++++++++++++++--- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index 0c0a3fc254..0b64b18a1d 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -27,7 +27,8 @@ class ProgressBar private $barChar; private $emptyBarChar = '-'; private $progressChar = '>'; - private $format = null; + private $format; + private $internalFormat; private $redrawFreq = 1; /** @@ -43,7 +44,6 @@ class ProgressBar private $formatLineCount; private $messages; private $overwrite = true; - private $formatSetByUser = false; private static $formatters; private static $formats; @@ -73,8 +73,6 @@ class ProgressBar } } - $this->setFormatInternal($this->determineBestFormat()); - $this->startTime = time(); } @@ -311,8 +309,8 @@ class ProgressBar */ public function setFormat($format) { - $this->formatSetByUser = true; - $this->setFormatInternal($format); + $this->format = null; + $this->internalFormat = $format; } /** @@ -338,10 +336,6 @@ class ProgressBar if (null !== $max) { $this->setMaxSteps($max); - - if (!$this->formatSetByUser) { - $this->setFormatInternal($this->determineBestFormat()); - } } $this->display(); @@ -438,6 +432,10 @@ class ProgressBar return; } + if (null === $this->format) { + $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat()); + } + // these 3 variables can be removed in favor of using $this in the closure when support for PHP 5.3 will be dropped. $self = $this; $output = $this->output; @@ -472,6 +470,10 @@ class ProgressBar return; } + if (null === $this->format) { + $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat()); + } + $this->overwrite(str_repeat("\n", $this->formatLineCount)); } @@ -480,7 +482,7 @@ class ProgressBar * * @param string $format The format */ - private function setFormatInternal($format) + private function setRealFormat($format) { // try to use the _nomax variant if available if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) { diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index dbcc6e2a8a..7d18c11847 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -106,25 +106,51 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase ); } - public function testFormatWhenMaxInConstructAndInStart() + public function testFormat() { + $expected = + $this->generateOutput(' 0/10 [>---------------------------] 0%'). + $this->generateOutput(' 10/10 [============================] 100%'). + $this->generateOutput(' 10/10 [============================] 100%') + ; + + // max in construct, no format $bar = new ProgressBar($output = $this->getOutputStream(), 10); $bar->start(); $bar->advance(10); $bar->finish(); rewind($output->getStream()); - $maxInConstruct = stream_get_contents($output->getStream()); + $this->assertEquals($expected, stream_get_contents($output->getStream())); + // max in start, no format $bar = new ProgressBar($output = $this->getOutputStream()); $bar->start(10); $bar->advance(10); $bar->finish(); rewind($output->getStream()); - $maxInStart = stream_get_contents($output->getStream()); + $this->assertEquals($expected, stream_get_contents($output->getStream())); - $this->assertEquals($maxInStart, $maxInConstruct); + // max in construct, explicit format before + $bar = new ProgressBar($output = $this->getOutputStream(), 10); + $bar->setFormat('normal'); + $bar->start(); + $bar->advance(10); + $bar->finish(); + + rewind($output->getStream()); + $this->assertEquals($expected, stream_get_contents($output->getStream())); + + // max in start, explicit format before + $bar = new ProgressBar($output = $this->getOutputStream()); + $bar->setFormat('normal'); + $bar->start(10); + $bar->advance(10); + $bar->finish(); + + rewind($output->getStream()); + $this->assertEquals($expected, stream_get_contents($output->getStream())); } public function testCustomizations() From 4ac8ff7e26d10fd7f122c288a26d90793cf2d1f9 Mon Sep 17 00:00:00 2001 From: Michele Orselli Date: Sat, 3 Oct 2015 17:44:30 +0200 Subject: [PATCH 4/7] adds validation messages missing italian translations --- .../Resources/translations/validators.it.xlf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf index 8366dcbb75..324c0d8d9f 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf @@ -302,6 +302,18 @@ An empty file is not allowed. Un file vuoto non è consentito. + + The host could not be resolved. + L'host non può essere risolto. + + + This value does not match the expected {{ charset }} charset. + Questo valore non corrisponde al charset {{ charset }}. + + + This is not a valid Business Identifier Code (BIC). + Questo valore non è un codice BIC valido. + From d1d0e041c216ed184dad2b3998dcbafa9e91904f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 11 Oct 2015 10:09:32 +0200 Subject: [PATCH 5/7] [ci] SymfonyTestsListener is now auto-registered --- phpunit | 9 +++++++++ phpunit.xml.dist | 4 ---- src/Symfony/Bridge/Doctrine/phpunit.xml.dist | 4 ---- src/Symfony/Bridge/Monolog/phpunit.xml.dist | 4 ---- src/Symfony/Bridge/Propel1/phpunit.xml.dist | 4 ---- src/Symfony/Bridge/ProxyManager/phpunit.xml.dist | 4 ---- src/Symfony/Bridge/Twig/phpunit.xml.dist | 4 ---- src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist | 4 ---- src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist | 4 ---- src/Symfony/Bundle/TwigBundle/phpunit.xml.dist | 4 ---- src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist | 4 ---- src/Symfony/Component/BrowserKit/phpunit.xml.dist | 4 ---- src/Symfony/Component/ClassLoader/phpunit.xml.dist | 4 ---- src/Symfony/Component/Config/phpunit.xml.dist | 4 ---- src/Symfony/Component/Console/phpunit.xml.dist | 4 ---- src/Symfony/Component/CssSelector/phpunit.xml.dist | 4 ---- src/Symfony/Component/Debug/phpunit.xml.dist | 4 ---- .../Component/DependencyInjection/phpunit.xml.dist | 4 ---- src/Symfony/Component/DomCrawler/phpunit.xml.dist | 4 ---- src/Symfony/Component/EventDispatcher/phpunit.xml.dist | 4 ---- src/Symfony/Component/Filesystem/phpunit.xml.dist | 4 ---- src/Symfony/Component/Finder/phpunit.xml.dist | 4 ---- src/Symfony/Component/Form/phpunit.xml.dist | 4 ---- src/Symfony/Component/HttpFoundation/phpunit.xml.dist | 4 ---- src/Symfony/Component/HttpKernel/phpunit.xml.dist | 4 ---- src/Symfony/Component/Intl/phpunit.xml.dist | 4 ---- src/Symfony/Component/Locale/phpunit.xml.dist | 4 ---- src/Symfony/Component/OptionsResolver/phpunit.xml.dist | 4 ---- src/Symfony/Component/Process/phpunit.xml.dist | 4 ---- src/Symfony/Component/PropertyAccess/phpunit.xml.dist | 4 ---- src/Symfony/Component/Routing/phpunit.xml.dist | 4 ---- src/Symfony/Component/Security/phpunit.xml.dist | 4 ---- src/Symfony/Component/Serializer/phpunit.xml.dist | 4 ---- src/Symfony/Component/Stopwatch/phpunit.xml.dist | 4 ---- src/Symfony/Component/Templating/phpunit.xml.dist | 4 ---- src/Symfony/Component/Translation/phpunit.xml.dist | 4 ---- src/Symfony/Component/Validator/phpunit.xml.dist | 4 ---- src/Symfony/Component/Yaml/phpunit.xml.dist | 4 ---- 38 files changed, 9 insertions(+), 148 deletions(-) diff --git a/phpunit b/phpunit index 3a39e107db..c65498522c 100755 --- a/phpunit +++ b/phpunit @@ -47,6 +47,15 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__ passthru("$COMPOSER remove --no-update symfony/yaml"); passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8@dev\""); passthru("$COMPOSER install --prefer-source --no-progress --ansi"); + file_put_contents('phpunit', <<nul 2>&1': 'rm -rf %s', str_replace('/', DIRECTORY_SEPARATOR, "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge"))); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4c89090162..e9c709d142 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -41,8 +41,4 @@ - - - - diff --git a/src/Symfony/Bridge/Doctrine/phpunit.xml.dist b/src/Symfony/Bridge/Doctrine/phpunit.xml.dist index 3692a77140..13409e6f0f 100644 --- a/src/Symfony/Bridge/Doctrine/phpunit.xml.dist +++ b/src/Symfony/Bridge/Doctrine/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Bridge/Monolog/phpunit.xml.dist b/src/Symfony/Bridge/Monolog/phpunit.xml.dist index 55fc79fd00..efd48709de 100644 --- a/src/Symfony/Bridge/Monolog/phpunit.xml.dist +++ b/src/Symfony/Bridge/Monolog/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Bridge/Propel1/phpunit.xml.dist b/src/Symfony/Bridge/Propel1/phpunit.xml.dist index 4691fb6d0f..507e12596c 100644 --- a/src/Symfony/Bridge/Propel1/phpunit.xml.dist +++ b/src/Symfony/Bridge/Propel1/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist b/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist index 2479485ca3..363805fdfa 100644 --- a/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist +++ b/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Bridge/Twig/phpunit.xml.dist b/src/Symfony/Bridge/Twig/phpunit.xml.dist index 6f40919cb1..d291324949 100644 --- a/src/Symfony/Bridge/Twig/phpunit.xml.dist +++ b/src/Symfony/Bridge/Twig/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist b/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist index 6d1abb32aa..eb7c0b0a97 100644 --- a/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist b/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist index 2fdc45986f..52f420ae5f 100644 --- a/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist b/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist index 0bf9c85154..715b0bfa87 100644 --- a/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist b/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist index 3c109396e2..767f3e066b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/BrowserKit/phpunit.xml.dist b/src/Symfony/Component/BrowserKit/phpunit.xml.dist index 0d4678bce3..d6ca28bf1c 100644 --- a/src/Symfony/Component/BrowserKit/phpunit.xml.dist +++ b/src/Symfony/Component/BrowserKit/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/ClassLoader/phpunit.xml.dist b/src/Symfony/Component/ClassLoader/phpunit.xml.dist index 982955b2db..a1b6c82c10 100644 --- a/src/Symfony/Component/ClassLoader/phpunit.xml.dist +++ b/src/Symfony/Component/ClassLoader/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/Config/phpunit.xml.dist b/src/Symfony/Component/Config/phpunit.xml.dist index 5f17ee0be3..2156534e9c 100644 --- a/src/Symfony/Component/Config/phpunit.xml.dist +++ b/src/Symfony/Component/Config/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/Console/phpunit.xml.dist b/src/Symfony/Component/Console/phpunit.xml.dist index a7b08dc3e6..729c433aa6 100644 --- a/src/Symfony/Component/Console/phpunit.xml.dist +++ b/src/Symfony/Component/Console/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/CssSelector/phpunit.xml.dist b/src/Symfony/Component/CssSelector/phpunit.xml.dist index 9e075e236b..bc57cfcdfa 100644 --- a/src/Symfony/Component/CssSelector/phpunit.xml.dist +++ b/src/Symfony/Component/CssSelector/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/Debug/phpunit.xml.dist b/src/Symfony/Component/Debug/phpunit.xml.dist index 118d82f340..e917660657 100644 --- a/src/Symfony/Component/Debug/phpunit.xml.dist +++ b/src/Symfony/Component/Debug/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Component/DependencyInjection/phpunit.xml.dist b/src/Symfony/Component/DependencyInjection/phpunit.xml.dist index 2276d0d6a5..17a217226d 100644 --- a/src/Symfony/Component/DependencyInjection/phpunit.xml.dist +++ b/src/Symfony/Component/DependencyInjection/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/DomCrawler/phpunit.xml.dist b/src/Symfony/Component/DomCrawler/phpunit.xml.dist index 8bccfa3c9b..d15dd6a48e 100644 --- a/src/Symfony/Component/DomCrawler/phpunit.xml.dist +++ b/src/Symfony/Component/DomCrawler/phpunit.xml.dist @@ -26,8 +26,4 @@ - - - - diff --git a/src/Symfony/Component/EventDispatcher/phpunit.xml.dist b/src/Symfony/Component/EventDispatcher/phpunit.xml.dist index d4c0f5b5bf..b14fde5750 100644 --- a/src/Symfony/Component/EventDispatcher/phpunit.xml.dist +++ b/src/Symfony/Component/EventDispatcher/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/Filesystem/phpunit.xml.dist b/src/Symfony/Component/Filesystem/phpunit.xml.dist index 9ccc35e5dc..32444185a1 100644 --- a/src/Symfony/Component/Filesystem/phpunit.xml.dist +++ b/src/Symfony/Component/Filesystem/phpunit.xml.dist @@ -23,8 +23,4 @@ - - - - diff --git a/src/Symfony/Component/Finder/phpunit.xml.dist b/src/Symfony/Component/Finder/phpunit.xml.dist index 7453b3ba45..bc38ccaa45 100644 --- a/src/Symfony/Component/Finder/phpunit.xml.dist +++ b/src/Symfony/Component/Finder/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Component/Form/phpunit.xml.dist b/src/Symfony/Component/Form/phpunit.xml.dist index 0d998244ec..104aee4b0b 100644 --- a/src/Symfony/Component/Form/phpunit.xml.dist +++ b/src/Symfony/Component/Form/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Component/HttpFoundation/phpunit.xml.dist b/src/Symfony/Component/HttpFoundation/phpunit.xml.dist index 4a7741afbe..b5b660a394 100644 --- a/src/Symfony/Component/HttpFoundation/phpunit.xml.dist +++ b/src/Symfony/Component/HttpFoundation/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/HttpKernel/phpunit.xml.dist b/src/Symfony/Component/HttpKernel/phpunit.xml.dist index 35f36ddd7d..7901a0b8b5 100644 --- a/src/Symfony/Component/HttpKernel/phpunit.xml.dist +++ b/src/Symfony/Component/HttpKernel/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Component/Intl/phpunit.xml.dist b/src/Symfony/Component/Intl/phpunit.xml.dist index b37ce8d292..d40a1582bb 100644 --- a/src/Symfony/Component/Intl/phpunit.xml.dist +++ b/src/Symfony/Component/Intl/phpunit.xml.dist @@ -30,8 +30,4 @@ - - - - diff --git a/src/Symfony/Component/Locale/phpunit.xml.dist b/src/Symfony/Component/Locale/phpunit.xml.dist index 1e9a853048..4633ca6f04 100644 --- a/src/Symfony/Component/Locale/phpunit.xml.dist +++ b/src/Symfony/Component/Locale/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/OptionsResolver/phpunit.xml.dist b/src/Symfony/Component/OptionsResolver/phpunit.xml.dist index fcf5910ffd..2398388768 100644 --- a/src/Symfony/Component/OptionsResolver/phpunit.xml.dist +++ b/src/Symfony/Component/OptionsResolver/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Component/Process/phpunit.xml.dist b/src/Symfony/Component/Process/phpunit.xml.dist index 0fa8cc348c..07b617be4b 100644 --- a/src/Symfony/Component/Process/phpunit.xml.dist +++ b/src/Symfony/Component/Process/phpunit.xml.dist @@ -23,8 +23,4 @@ - - - - diff --git a/src/Symfony/Component/PropertyAccess/phpunit.xml.dist b/src/Symfony/Component/PropertyAccess/phpunit.xml.dist index 3e96e9b5e9..99858f7b95 100644 --- a/src/Symfony/Component/PropertyAccess/phpunit.xml.dist +++ b/src/Symfony/Component/PropertyAccess/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Component/Routing/phpunit.xml.dist b/src/Symfony/Component/Routing/phpunit.xml.dist index 6b2e69ed11..fae243c815 100644 --- a/src/Symfony/Component/Routing/phpunit.xml.dist +++ b/src/Symfony/Component/Routing/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Component/Security/phpunit.xml.dist b/src/Symfony/Component/Security/phpunit.xml.dist index 8919f326a1..9a20f91498 100644 --- a/src/Symfony/Component/Security/phpunit.xml.dist +++ b/src/Symfony/Component/Security/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Component/Serializer/phpunit.xml.dist b/src/Symfony/Component/Serializer/phpunit.xml.dist index 7afdf5434a..da0540137b 100644 --- a/src/Symfony/Component/Serializer/phpunit.xml.dist +++ b/src/Symfony/Component/Serializer/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Component/Stopwatch/phpunit.xml.dist b/src/Symfony/Component/Stopwatch/phpunit.xml.dist index c617896f02..38078d25bb 100644 --- a/src/Symfony/Component/Stopwatch/phpunit.xml.dist +++ b/src/Symfony/Component/Stopwatch/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - diff --git a/src/Symfony/Component/Templating/phpunit.xml.dist b/src/Symfony/Component/Templating/phpunit.xml.dist index 8a06747f37..3da1f5de13 100644 --- a/src/Symfony/Component/Templating/phpunit.xml.dist +++ b/src/Symfony/Component/Templating/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/Translation/phpunit.xml.dist b/src/Symfony/Component/Translation/phpunit.xml.dist index c908a7985f..16cca4afb7 100644 --- a/src/Symfony/Component/Translation/phpunit.xml.dist +++ b/src/Symfony/Component/Translation/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/Validator/phpunit.xml.dist b/src/Symfony/Component/Validator/phpunit.xml.dist index 57b15e0165..1bf4391c3c 100644 --- a/src/Symfony/Component/Validator/phpunit.xml.dist +++ b/src/Symfony/Component/Validator/phpunit.xml.dist @@ -25,8 +25,4 @@ - - - - diff --git a/src/Symfony/Component/Yaml/phpunit.xml.dist b/src/Symfony/Component/Yaml/phpunit.xml.dist index 93ab1cd204..8f7741fe39 100644 --- a/src/Symfony/Component/Yaml/phpunit.xml.dist +++ b/src/Symfony/Component/Yaml/phpunit.xml.dist @@ -24,8 +24,4 @@ - - - - From 3c0b441371bdb697cbfce6aba342563573c23b1f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 12 Oct 2015 11:03:54 +0200 Subject: [PATCH 6/7] [ci] Fix tests requirements --- .travis.yml | 2 +- appveyor.yml | 7 ++++--- .../Tests/ApcUniversalClassLoaderTest.php | 6 +++--- .../DateTimeToStringTransformerTest.php | 5 +---- .../Core/EventListener/TrimListenerTest.php | 5 +---- .../Profiler/MongoDbProfilerStorageTest.php | 17 +++++++++-------- .../Profiler/SqliteProfilerStorageTest.php | 6 +++--- .../Security/Tests/Acl/Dbal/AclProviderTest.php | 7 +++---- .../Tests/Acl/Dbal/MutableAclProviderTest.php | 7 +++---- .../Core/Encoder/BCryptPasswordEncoderTest.php | 17 ++++++----------- .../Tests/Mapping/Cache/ApcCacheTest.php | 5 ++++- 11 files changed, 38 insertions(+), 46 deletions(-) diff --git a/.travis.yml b/.travis.yml index e58001df17..2d1dcbfe6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_install: - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi; - if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then phpenv config-rm xdebug.ini; fi; - if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi; - - if [[ "$TRAVIS_PHP_VERSION" =~ 5.[34] ]]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi; + - if [[ "$TRAVIS_PHP_VERSION" =~ 5.[34] ]]; then echo -e "extension = apc.so\napc.enable_cli = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi; - if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Let's continue without memcache extension"; fi; - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php -i; fi; - if [ "$deps" != "skip" ]; then ./phpunit install; fi; diff --git a/appveyor.yml b/appveyor.yml index fd9153e47e..b9a95c9fd7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,8 +26,8 @@ install: - IF %PHP%==1 cd ext - IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/php_intl-3.0.0-5.3-nts-vc9-x86.zip - IF %PHP%==1 7z x php_intl-3.0.0-5.3-nts-vc9-x86.zip -y > 7z.log - - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apc/3.1.13/php_apc-3.1.13-5.3-nts-vc9-x86.zip - - IF %PHP%==1 7z x php_apc-3.1.13-5.3-nts-vc9-x86.zip -y > 7z.log + - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apcu/4.0.7/php_apcu-4.0.7-5.3-nts-vc9-x86.zip + - IF %PHP%==1 7z x php_apcu-4.0.7-5.3-nts-vc9-x86.zip -y > 7z.log - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/php_memcache-3.0.8-5.3-nts-vc9-x86.zip - IF %PHP%==1 7z x php_memcache-3.0.8-5.3-nts-vc9-x86.zip -y > 7z.log - IF %PHP%==1 cd .. @@ -38,7 +38,8 @@ install: - IF %PHP%==1 echo extension_dir=ext >> php.ini-min - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini-min - IF %PHP%==1 copy /Y php.ini-min php.ini-max - - IF %PHP%==1 echo extension=php_apc.dll >> php.ini-max + - IF %PHP%==1 echo extension=php_apcu.dll >> php.ini-max + - IF %PHP%==1 echo apc.enable_cli=1 >> php.ini-max - IF %PHP%==1 echo extension=php_intl.dll >> php.ini-max - IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini-max - IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini-max diff --git a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php index e468057f7f..40046f5530 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php @@ -20,10 +20,10 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli'))) { - $this->markTestSkipped('The apc extension is available, but not enabled.'); - } else { + if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) { apc_clear_cache('user'); + } else { + $this->markTestSkipped('APC is not enabled.'); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index e50ba191d0..886d3b952a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -122,13 +122,10 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase /** * @dataProvider dataProvider + * @requires PHP 5.3.7 */ public function testReverseTransformUsingPipe($format, $input, $output) { - if (PHP_VERSION_ID < 50307) { - $this->markTestSkipped('Pipe usage requires PHP 5.3.7 or newer.'); - } - $reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, true); $output = new \DateTime($output); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php index 3818c7861f..e87f2dcd51 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php @@ -42,13 +42,10 @@ class TrimListenerTest extends \PHPUnit_Framework_TestCase /** * @dataProvider spaceProvider + * @requires extension mbstring */ public function testTrimUtf8Separators($hex) { - if (!function_exists('mb_convert_encoding')) { - $this->markTestSkipped('The "mb_convert_encoding" function is not available'); - } - // Convert hexadecimal representation into binary // H: hex string, high nibble first (UCS-2BE) // *: repeat until end of string diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php index 29525fe6bd..6550dc28d1 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php @@ -47,19 +47,20 @@ class MongoDbProfilerStorageTestDataCollector extends DataCollector } } +/** + * @requires extension mongo + */ class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest { protected static $storage; public static function setUpBeforeClass() { - if (extension_loaded('mongo')) { - self::$storage = new DummyMongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400); - try { - self::$storage->getMongo(); - } catch (\MongoConnectionException $e) { - self::$storage = null; - } + self::$storage = new DummyMongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400); + try { + self::$storage->getMongo(); + } catch (\MongoConnectionException $e) { + self::$storage = null; } } @@ -159,7 +160,7 @@ class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest if (self::$storage) { self::$storage->purge(); } else { - $this->markTestSkipped('MongoDbProfilerStorageTest requires the mongo PHP extension and a MongoDB server on localhost'); + $this->markTestSkipped('A MongoDB server on localhost is required.'); } } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php index 43546c1a16..4a1430321b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php @@ -13,6 +13,9 @@ namespace Symfony\Component\HttpKernel\Tests\Profiler; use Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage; +/** + * @requires extension pdo_sqlite + */ class SqliteProfilerStorageTest extends AbstractProfilerStorageTest { protected static $dbFile; @@ -34,9 +37,6 @@ class SqliteProfilerStorageTest extends AbstractProfilerStorageTest protected function setUp() { - if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) { - $this->markTestSkipped('This test requires SQLite support in your environment'); - } self::$storage->purge(); } diff --git a/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderTest.php b/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderTest.php index 7ca493f70d..afbcb56dcf 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderTest.php @@ -17,6 +17,9 @@ use Symfony\Component\Security\Acl\Domain\ObjectIdentity; use Symfony\Component\Security\Acl\Dbal\Schema; use Doctrine\DBAL\DriverManager; +/** + * @requires extension pdo_sqlite + */ class AclProviderTest extends \PHPUnit_Framework_TestCase { protected $con; @@ -141,10 +144,6 @@ class AclProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) { - self::markTestSkipped('This test requires SQLite support in your environment'); - } - $this->con = DriverManager::getConnection(array( 'driver' => 'pdo_sqlite', 'memory' => true, diff --git a/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php b/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php index 00500f8779..32134062f0 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php @@ -27,6 +27,9 @@ use Symfony\Component\Security\Acl\Dbal\Schema; use Doctrine\DBAL\DriverManager; use Symfony\Component\Security\Acl\Domain\ObjectIdentity; +/** + * @requires extension pdo_sqlite + */ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase { protected $con; @@ -483,10 +486,6 @@ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) { - self::markTestSkipped('This test requires SQLite support in your environment'); - } - $this->con = DriverManager::getConnection(array( 'driver' => 'pdo_sqlite', 'memory' => true, diff --git a/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php b/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php index 3f8ba86467..076d954f4b 100644 --- a/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php @@ -45,32 +45,27 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase } } + /** + * @requires PHP 5.3.7 + */ public function testResultLength() { - $this->skipIfPhpVersionIsNotSupported(); - $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertEquals(60, strlen($result)); } + /** + * @requires PHP 5.3.7 + */ public function testValidation() { - $this->skipIfPhpVersionIsNotSupported(); - $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); } - private function skipIfPhpVersionIsNotSupported() - { - if (PHP_VERSION_ID < 50307) { - $this->markTestSkipped('Requires PHP >= 5.3.7'); - } - } - /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php index 9db9b74061..10dafd3c21 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php @@ -13,11 +13,14 @@ namespace Symfony\Component\Validator\Tests\Mapping\Cache; use Symfony\Component\Validator\Mapping\Cache\ApcCache; +/** + * @requires extension apc + */ class ApcCacheTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - if (!ini_get('apc.enable') || !ini_get('apc.enable_cli')) { + if (!ini_get('apc.enabled') || !ini_get('apc.enable_cli')) { $this->markTestSkipped('APC is not enabled.'); } } From d36e284192507633a55985b8c60f5eddbf4cea8a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 12 Oct 2015 11:27:31 +0200 Subject: [PATCH 7/7] Fix merge --- .../Component/ClassLoader/Tests/ApcClassLoaderTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/ClassLoader/Tests/ApcClassLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ApcClassLoaderTest.php index 8090c5e175..e929d0e7c4 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ApcClassLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ApcClassLoaderTest.php @@ -21,10 +21,10 @@ class ApcClassLoaderTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli'))) { - $this->markTestSkipped('The apc extension is available, but not enabled.'); - } else { + if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) { apc_clear_cache('user'); + } else { + $this->markTestSkipped('APC is not enabled.'); } }