From cc9cc37e790a4dd6fa05e2b1d9079215d59752b7 Mon Sep 17 00:00:00 2001 From: catch Date: Wed, 26 Mar 2014 14:45:08 +0100 Subject: [PATCH 01/19] Avoid levenshtein comparison when using ContainerBuilder. --- .../DependencyInjection/ContainerBuilder.php | 60 ++++++++----------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index dc5738a5cf..85ea49e67a 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -461,52 +461,44 @@ class ContainerBuilder extends Container implements TaggedContainerInterface public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { $id = strtolower($id); + if ($service = parent::get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE)) { + return $service; + } + if (isset($this->loading[$id])) { + throw new LogicException(sprintf('The service "%s" has a circular reference to itself.', $id), 0, $e); + } + + if (!$this->hasDefinition($id) && isset($this->aliasDefinitions[$id])) { + return $this->get($this->aliasDefinitions[$id]); + } try { - return parent::get($id, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); - } catch (InactiveScopeException $e) { + $definition = $this->getDefinition($id); + } catch (InvalidArgumentException $e) { if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { return null; } throw $e; - } catch (InvalidArgumentException $e) { - if (isset($this->loading[$id])) { - throw new LogicException(sprintf('The service "%s" has a circular reference to itself.', $id), 0, $e); - } + } - if (!$this->hasDefinition($id) && isset($this->aliasDefinitions[$id])) { - return $this->get($this->aliasDefinitions[$id]); - } - - try { - $definition = $this->getDefinition($id); - } catch (InvalidArgumentException $e) { - if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { - return null; - } - - throw $e; - } - - $this->loading[$id] = true; - - try { - $service = $this->createService($definition, $id); - } catch (\Exception $e) { - unset($this->loading[$id]); - - if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { - return null; - } - - throw $e; - } + $this->loading[$id] = true; + try { + $service = $this->createService($definition, $id); + } catch (\Exception $e) { unset($this->loading[$id]); - return $service; + if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { + return null; + } + + throw $e; } + + unset($this->loading[$id]); + + return $service; } /** From f4ffd95713b12d6d46319820ed951a7950524b97 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 27 Mar 2014 19:14:17 +0100 Subject: [PATCH 02/19] fixed CS --- .../Component/DependencyInjection/ContainerBuilder.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 85ea49e67a..f8101b5963 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -461,9 +461,11 @@ class ContainerBuilder extends Container implements TaggedContainerInterface public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { $id = strtolower($id); + if ($service = parent::get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE)) { - return $service; + return $service; } + if (isset($this->loading[$id])) { throw new LogicException(sprintf('The service "%s" has a circular reference to itself.', $id), 0, $e); } From 73d56f7a1a7e2aaf7cb00230af25ca208330ce6d Mon Sep 17 00:00:00 2001 From: Koen Kuipers Date: Thu, 27 Mar 2014 13:42:59 +0100 Subject: [PATCH 03/19] Fixed bug in ChoiceType triggering a warning when not using utf-8 This fixes issue #10409 by not using json_encode anymore, but serialize instead. --- src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 692f91e95c..83fe717f0d 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -166,7 +166,7 @@ class ChoiceType extends AbstractType $choices = null !== $options['choices'] ? $options['choices'] : array(); // Reuse existing choice lists in order to increase performance - $hash = md5(json_encode(array($choices, $options['preferred_choices']))); + $hash = hash('sha256', serialize(array($choices, $options['preferred_choices']))); if (!isset($choiceListCache[$hash])) { $choiceListCache[$hash] = new SimpleChoiceList($choices, $options['preferred_choices']); From 18dc9a7f5f98b757afa7a223fe6c33729e154ba6 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Fri, 28 Mar 2014 11:13:11 +0100 Subject: [PATCH 04/19] Added test case for 4c6a2d15095c13b2a35751b2b2712b183be489c4 --- .../Extension/Core/Type/ChoiceTypeTest.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index 3da49dfa6a..2e99c2c774 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -1216,6 +1216,47 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase )); } + // https://github.com/symfony/symfony/issues/10409 + public function testReuseNonUtf8ChoiceLists() + { + $form1 = $this->factory->createNamed('name', 'choice', null, array( + 'choices' => array( + 'meter' => 'm', + 'millimeter' => 'mm', + 'micrometer' => chr(181).'meter', + ), + )); + + $form2 = $this->factory->createNamed('name', 'choice', null, array( + 'choices' => array( + 'meter' => 'm', + 'millimeter' => 'mm', + 'micrometer' => chr(181).'meter', + ), + )); + + $form3 = $this->factory->createNamed('name', 'choice', null, array( + 'choices' => array( + 'meter' => 'm', + 'millimeter' => 'mm', + 'micrometer' => null, + ), + )); + + // $form1 and $form2 use the same ChoiceList + $this->assertSame( + $form1->getConfig()->getOption('choice_list'), + $form2->getConfig()->getOption('choice_list') + ); + + // $form3 doesn't, but used to use the same when using json_encode() + // instead of serialize for the hashing algorithm + $this->assertNotSame( + $form1->getConfig()->getOption('choice_list'), + $form3->getConfig()->getOption('choice_list') + ); + } + public function testInitializeWithDefaultObjectChoice() { $obj1 = (object) array('value' => 'a', 'label' => 'A'); From 8a19b9ac08f64ccdbee57f3a23acb59d6d675aa1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Mar 2014 11:34:27 +0100 Subject: [PATCH 05/19] fixed CS --- .../Form/Tests/Extension/Core/Type/ChoiceTypeTest.php | 4 ++-- .../Component/Routing/Tests/Loader/XmlFileLoaderTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index 2e99c2c774..b251da031c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -380,7 +380,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase $form->submit('foobar'); - $this->assertSame(null, $form->getData()); + $this->assertNull($form->getData()); $this->assertSame('foobar', $form->getViewData()); $this->assertEmpty($form->getExtraData()); $this->assertFalse($form->isSynchronized()); @@ -445,7 +445,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase $form->submit('foobar'); - $this->assertSame(null, $form->getData()); + $this->assertNull($form->getData()); $this->assertSame('foobar', $form->getViewData()); $this->assertEmpty($form->getExtraData()); $this->assertFalse($form->isSynchronized()); diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index 9f038c1611..ee1dc5ca90 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -68,7 +68,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); $this->assertSame('\w+', $route->getRequirement('slug')); $this->assertSame('en|fr|de', $route->getRequirement('_locale')); - $this->assertSame(null, $route->getDefault('slug')); + $this->assertNull($route->getDefault('slug')); $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); } From 79540d4b6e4cf367a2fb187e2452c42fbfb1a330 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Mar 2014 09:04:42 +0100 Subject: [PATCH 06/19] fixed the profiler when an uncalled listener throws an exception when instantiated --- .../Resources/views/Collector/events.html.twig | 15 +++++++++++++-- .../HttpKernel/Debug/TraceableEventDispatcher.php | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig index 6072ff69f2..0607aa8a3b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig @@ -36,9 +36,9 @@ {% endfor %} - {% if collector.notcalledlisteners %} -

Not Called Listeners

+

Not Called Listeners

+ {% if collector.notcalledlisteners %} @@ -52,6 +52,17 @@ {% endfor %}
Event name
+ {% else %} +

+ No uncalled listeners. +

+

+ + All listeners were called for this request or an error occurred + when trying to collect uncalled listeners (in which case check the + logs to get more information). + +

{% endif %} {% endblock %} diff --git a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php index de06ce2ae1..4cdd9291bc 100644 --- a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php @@ -160,9 +160,19 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve */ public function getNotCalledListeners() { - $notCalled = array(); + try { + $allListeners = $this->getListeners(); + } catch (\Exception $e) { + if (null !== $this->logger) { + $this->logger->info(sprintf('An exception was thrown while getting the uncalled listeners (%s)', $e->getMessage()), array('exception' => $e)); + } - foreach ($this->getListeners() as $name => $listeners) { + // unable to retrieve the uncalled listeners + return array(); + } + + $notCalled = array(); + foreach ($allListeners as $name => $listeners) { foreach ($listeners as $listener) { $info = $this->getListenerInfo($listener, null, $name); if (!isset($this->called[$name.'.'.$info['pretty']])) { From dc0f8f9df8cdd53c3c9a71b86b944fb1d2992b29 Mon Sep 17 00:00:00 2001 From: Ioan Negulescu Date: Fri, 28 Mar 2014 22:55:16 -0700 Subject: [PATCH 07/19] Fix class names in ApcUniversalClassLoader tests. --- .../Tests/ApcUniversalClassLoaderTest.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php index 9a7acfd716..38a17f2845 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php @@ -58,10 +58,8 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase public function getLoadClassTests() { return array( - array('\\Apc\\Namespaced\\Foo', '\\Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'), + array('\\Apc\\Namespaced\\Foo', 'Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'), array('Apc_Pearlike_Foo', 'Apc_Pearlike_Foo', '->loadClass() loads Apc_Pearlike_Foo class'), - array('\\Apc\\Namespaced\\Bar', '\\Apc\\Namespaced\\Bar', '->loadClass() loads Apc\Namespaced\Bar class with a leading slash'), - array('Apc_Pearlike_Bar', '\\Apc_Pearlike_Bar', '->loadClass() loads Apc_Pearlike_Bar class with a leading slash'), ); } @@ -82,9 +80,9 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase public function getLoadClassFromFallbackTests() { return array( - array('\\Apc\\Namespaced\\Baz', '\\Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'), + array('\\Apc\\Namespaced\\Baz', 'Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'), array('Apc_Pearlike_Baz', 'Apc_Pearlike_Baz', '->loadClass() loads Apc_Pearlike_Baz class'), - array('\\Apc\\Namespaced\\FooBar', '\\Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'), + array('\\Apc\\Namespaced\\FooBar', 'Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'), array('Apc_Pearlike_FooBar', 'Apc_Pearlike_FooBar', '->loadClass() loads Apc_Pearlike_Baz class from fallback dir'), ); } @@ -110,7 +108,7 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', ), - '\Apc\NamespaceCollision\A\Foo', + 'Apc\NamespaceCollision\A\Foo', '->loadClass() loads NamespaceCollision\A\Foo from alpha.', ), array( @@ -118,7 +116,7 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', ), - '\Apc\NamespaceCollision\A\Bar', + 'Apc\NamespaceCollision\A\Bar', '->loadClass() loads NamespaceCollision\A\Bar from alpha.', ), array( @@ -126,7 +124,7 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', ), - '\Apc\NamespaceCollision\A\B\Foo', + 'Apc\NamespaceCollision\A\B\Foo', '->loadClass() loads NamespaceCollision\A\B\Foo from beta.', ), array( @@ -134,7 +132,7 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', ), - '\Apc\NamespaceCollision\A\B\Bar', + 'Apc\NamespaceCollision\A\B\Bar', '->loadClass() loads NamespaceCollision\A\B\Bar from beta.', ), ); From 8fbea0fe4d93bc58ec554bfeef3d873136f8a5b0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Mar 2014 09:34:36 +0100 Subject: [PATCH 08/19] [Process] fixed HHVM usage on the CLI --- src/Symfony/Component/Process/PhpExecutableFinder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index 9001f41095..cda86995a4 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -34,8 +34,8 @@ class PhpExecutableFinder public function find() { // HHVM support - if (defined('HHVM_VERSION') && false !== $hhvm = getenv('PHP_BINARY')) { - return $hhvm; + if (defined('HHVM_VERSION')) { + return (false !== ($hhvm = getenv('PHP_BINARY')) ? $hhvm : PHP_BINARY).' --php'; } // PHP_BINARY return the current sapi executable From 73189b1774dfca1b96f78d9166af6f233a86d168 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Mar 2014 09:34:56 +0100 Subject: [PATCH 09/19] upgraded PHPUnit to version 4 for better HHVM support --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 85a1f7a074..275ef31519 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,9 @@ before_script: - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - wget https://phar.phpunit.de/phpunit.phar && chmod +x phpunit.phar && sudo mv phpunit.phar /usr/local/bin/phpunit - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install script: - - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' || exit 1 - - echo "Running tests requiring tty"; phpunit --group tty + - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; /usr/local/bin/phpunit --exclude-group tty,benchmark {};' || exit 1 + - echo "Running tests requiring tty"; /usr/local/bin/phpunit --group tty From 9e6af955f5f4cdd460fd58dbbc86ed1b49c877f6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Mar 2014 09:56:31 +0100 Subject: [PATCH 10/19] fixed float comparison in unit tests for HHVM --- .../Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index e41252c497..c7801f4300 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -684,7 +684,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase { $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE); - $this->assertSame($expectedValue, $parsedValue); + $this->assertEquals($expectedValue, $parsedValue, '', 0.001); } public function parseTypeDoubleProvider() From 89742b0275726f9208594f3f050e88ca90009dad Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Mar 2014 07:23:46 +0100 Subject: [PATCH 11/19] tweaked Travis configuration to get more tests running --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 275ef31519..5641aadf92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,9 +18,10 @@ before_script: - travis_retry sudo apt-get install parallel - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so\napc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - sudo locale-gen fr_FR.UTF-8 && sudo update-locale - wget https://phar.phpunit.de/phpunit.phar && chmod +x phpunit.phar && sudo mv phpunit.phar /usr/local/bin/phpunit - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install From 91e226e06e72d1d5ab7f20ec280af579c2a8c454 Mon Sep 17 00:00:00 2001 From: Tim Nagel Date: Mon, 21 Jan 2013 11:11:02 +1100 Subject: [PATCH 12/19] Fixes URL validator to accept single part urls --- .../Component/Validator/Constraints/UrlValidator.php | 8 ++++---- .../Validator/Tests/Constraints/UrlValidatorTest.php | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php index 9b0f9de651..b2ea7e1b5f 100644 --- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -25,10 +25,10 @@ class UrlValidator extends ConstraintValidator const PATTERN = '~^ (%s):// # protocol ( - ([\pL\pN\pS-]+\.)+([\pL]|xn\-\-[\pL\pN-]+)+ # a domain name - | # or - \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # a IP address - | # or + ([\pL\pN\pS-\.])+(\.?([\pL]|xn\-\-[\pL\pN-]+)+\.?) # a domain name + | # or + \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # a IP address + | # or \[ (?:(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-f]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){4})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,1}(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){3})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,2}(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){2})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,3}(?:(?:[0-9a-f]{1,4})))?::(?:(?:[0-9a-f]{1,4})):)(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,4}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,5}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,6}(?:(?:[0-9a-f]{1,4})))?::)))) \] # a IPv6 address diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index e74bc18c40..1cf4bb4d22 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -72,6 +72,7 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase return array( array('http://a.pl'), array('http://www.google.com'), + array('http://www.google.com.'), array('http://www.google.museum'), array('https://google.com/'), array('https://google.com:80/'), @@ -85,6 +86,7 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase array('http://symfony.com/#?'), array('http://www.symfony.com/doc/current/book/validation.html#supported-constraints'), array('http://very.long.domain.name.com/'), + array('http://localhost/'), array('http://127.0.0.1/'), array('http://127.0.0.1:80/'), array('http://[::1]/'), @@ -152,6 +154,7 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase array('http://127.0.0.1:aa/'), array('ftp://[::1]/'), array('http://[::1'), + array('http://hello.☎/'), ); } From 6bb355e2fd974f41db417f3c50428514050c7110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adria=CC=80=20Lo=CC=81pez=20Lozano?= Date: Wed, 22 Jan 2014 16:19:57 +0100 Subject: [PATCH 13/19] [Form] Added check for parent disabled status in Button form elements The Button form element did not check for the parent disabled configuration status, making them behave differently to all other form widgets. --- src/Symfony/Component/Form/Button.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Button.php b/src/Symfony/Component/Form/Button.php index f12d11afe4..2d7ccd1569 100644 --- a/src/Symfony/Component/Form/Button.php +++ b/src/Symfony/Component/Form/Button.php @@ -321,7 +321,11 @@ class Button implements \IteratorAggregate, FormInterface */ public function isDisabled() { - return $this->config->getDisabled(); + if (null === $this->parent || !$this->parent->isDisabled()) { + return $this->config->getDisabled(); + } + + return true; } /** From ebfee723c9f28a9ea8519e501cf95e84439687a2 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Mon, 31 Mar 2014 11:59:34 +0200 Subject: [PATCH 14/19] [Form] Added test for disabling buttons --- src/Symfony/Component/Form/ButtonBuilder.php | 8 +++ .../Component/Form/Tests/ButtonTest.php | 70 +++++++++++++++++++ .../Component/Form/Tests/SimpleFormTest.php | 36 ++++------ 3 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 src/Symfony/Component/Form/Tests/ButtonTest.php diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index 9146c69352..f9b0546b1f 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -252,6 +252,8 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface public function setAttribute($name, $value) { $this->attributes[$name] = $value; + + return $this; } /** @@ -260,6 +262,8 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface public function setAttributes(array $attributes) { $this->attributes = $attributes; + + return $this; } /** @@ -286,6 +290,8 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface public function setDisabled($disabled) { $this->disabled = $disabled; + + return $this; } /** @@ -410,6 +416,8 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface public function setType(ResolvedFormTypeInterface $type) { $this->type = $type; + + return $this; } /** diff --git a/src/Symfony/Component/Form/Tests/ButtonTest.php b/src/Symfony/Component/Form/Tests/ButtonTest.php new file mode 100644 index 0000000000..b0c766c73c --- /dev/null +++ b/src/Symfony/Component/Form/Tests/ButtonTest.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests; + +use Symfony\Component\Form\ButtonBuilder; +use Symfony\Component\Form\FormBuilder; + +/** + * @author Bernhard Schussek + */ +class ButtonTest extends \PHPUnit_Framework_TestCase +{ + private $dispatcher; + + private $factory; + + protected function setUp() + { + $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + } + + /** + * @dataProvider getDisabledStates + */ + public function testDisabledIfParentIsDisabled($parentDisabled, $buttonDisabled, $result) + { + $form = $this->getFormBuilder('form') + ->setDisabled($parentDisabled) + ->getForm(); + + $button = $this->getButtonBuilder('button') + ->setDisabled($buttonDisabled) + ->getForm(); + + $button->setParent($form); + + $this->assertSame($result, $button->isDisabled()); + } + + public function getDisabledStates() + { + return array( + // parent, button, result + array(true, true, true), + array(true, false, true), + array(false, true, true), + array(false, false, false), + ); + } + + private function getButtonBuilder($name) + { + return new ButtonBuilder($name); + } + + private function getFormBuilder($name) + { + return new FormBuilder($name, null, $this->dispatcher, $this->factory); + } +} diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index bedad6761f..d6d3238b42 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -170,34 +170,28 @@ class SimpleFormTest extends AbstractFormTest $this->assertFalse($child->isRequired()); } - public function testAlwaysDisabledIfParentDisabled() + /** + * @dataProvider getDisabledStates + */ + public function testAlwaysDisabledIfParentDisabled($parentDisabled, $disabled, $result) { - $parent = $this->getBuilder()->setDisabled(true)->getForm(); - $child = $this->getBuilder()->setDisabled(false)->getForm(); + $parent = $this->getBuilder()->setDisabled($parentDisabled)->getForm(); + $child = $this->getBuilder()->setDisabled($disabled)->getForm(); $child->setParent($parent); - $this->assertTrue($child->isDisabled()); + $this->assertSame($result, $child->isDisabled()); } - public function testDisabled() + public function getDisabledStates() { - $parent = $this->getBuilder()->setDisabled(false)->getForm(); - $child = $this->getBuilder()->setDisabled(true)->getForm(); - - $child->setParent($parent); - - $this->assertTrue($child->isDisabled()); - } - - public function testNotDisabled() - { - $parent = $this->getBuilder()->setDisabled(false)->getForm(); - $child = $this->getBuilder()->setDisabled(false)->getForm(); - - $child->setParent($parent); - - $this->assertFalse($child->isDisabled()); + return array( + // parent, button, result + array(true, true, true), + array(true, false, true), + array(false, true, true), + array(false, false, false), + ); } public function testGetRootReturnsRootOfParent() From c2ffefd0ef28f265b34cda117667008df7deb9e3 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 31 Mar 2014 11:35:42 +0200 Subject: [PATCH 15/19] Use `Filesystem::chmod` instead of `chmod` when dumping file This adds consistency as discussed in https://github.com/symfony/symfony/commit/ca5eea5c1922688685d104f962bc5d16626ce05d#commitcomment-5804089 --- .../Compiler/CompilerDebugDumpPass.php | 8 ++++++-- .../Compiler/ContainerBuilderDebugDumpPass.php | 8 ++++++-- src/Symfony/Component/Config/ConfigCache.php | 16 +++++++++++++--- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php index 28ad7082fa..f152ce8c50 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php @@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; class CompilerDebugDumpPass implements CompilerPassInterface @@ -24,8 +25,11 @@ class CompilerDebugDumpPass implements CompilerPassInterface $filesystem = new Filesystem(); $filesystem->dumpFile($filename, implode("\n", $container->getCompiler()->getLog()), null); - // discard chmod failure (some filesystem may not support it) - @chmod($filename, 0666 & ~umask()); + try { + $filesystem->chmod($filename, 0666, umask()); + } catch (IOException $e) { + // discard chmod failure (some filesystem may not support it) + } } public static function getCompilerLogFilename(ContainerInterface $container) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php index 6cf52b6522..467ecff283 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php @@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\XmlDumper; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; /** @@ -31,7 +32,10 @@ class ContainerBuilderDebugDumpPass implements CompilerPassInterface $filename = $container->getParameter('debug.container.dump'); $filesystem = new Filesystem(); $filesystem->dumpFile($filename, $dumper->dump(), null); - // discard chmod failure (some filesystem may not support it) - @chmod($filename, 0666 & ~umask()); + try { + $filesystem->chmod($filename, 0666, umask()); + } catch (IOException $e) { + // discard chmod failure (some filesystem may not support it) + } } } diff --git a/src/Symfony/Component/Config/ConfigCache.php b/src/Symfony/Component/Config/ConfigCache.php index 73de9c2e5f..868a0572eb 100644 --- a/src/Symfony/Component/Config/ConfigCache.php +++ b/src/Symfony/Component/Config/ConfigCache.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Config; use Symfony\Component\Config\Resource\ResourceInterface; +use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; /** @@ -93,14 +94,23 @@ class ConfigCache */ public function write($content, array $metadata = null) { - $mode = 0666 & ~umask(); + $mode = 0666; + $umask = umask(); $filesystem = new Filesystem(); $filesystem->dumpFile($this->file, $content, null); - @chmod($this->file, $mode); + try { + $filesystem->chmod($this->file, $mode, $umask); + } catch (IOException $e) { + // discard chmod failure (some filesystem may not support it) + } if (null !== $metadata && true === $this->debug) { $filesystem->dumpFile($this->getMetaFile(), serialize($metadata), null); - @chmod($this->getMetaFile(), $mode); + try { + $filesystem->chmod($this->getMetaFile(), $mode, $umask); + } catch (IOException $e) { + // discard chmod failure (some filesystem may not support it) + } } } From 8882dad46edb4c1180a3a7a536683bec7a02baac Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 31 Mar 2014 22:49:46 +0100 Subject: [PATCH 16/19] Remove an unused argument. --- src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 7cb6343699..2c622492c8 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -522,7 +522,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface protected function lock(Request $request, Response $entry) { // try to acquire a lock to call the backend - $lock = $this->store->lock($request, $entry); + $lock = $this->store->lock($request); // there is already another process calling the backend if (true !== $lock) { From 9438f88af07a8ac6339ab772079247c017e12ad0 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 1 Apr 2014 15:48:06 +0100 Subject: [PATCH 17/19] [Security] Replace exception mocks with actual exception instances. It is done for two reasons: * consistency - we use real exception objects in most of the code * latest phpunit does not like the way we were creating mocks for exceptions (it could be also fixed by letting phpunit to call the original constructor) --- .../AuthenticationProviderManagerTest.php | 2 +- .../Provider/DaoAuthenticationProviderTest.php | 5 +++-- ...reAuthenticatedAuthenticationProviderTest.php | 3 ++- .../RememberMeAuthenticationProviderTest.php | 4 ++-- .../Provider/UserAuthenticationProviderTest.php | 16 +++++++++------- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Security/Tests/Core/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Tests/Core/Authentication/AuthenticationProviderManagerTest.php index 4120995ecb..32e6cf7923 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authentication/AuthenticationProviderManagerTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authentication/AuthenticationProviderManagerTest.php @@ -129,7 +129,7 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase } elseif (null !== $exception) { $provider->expects($this->once()) ->method('authenticate') - ->will($this->throwException($this->getMock($exception, null, array(), '', false))) + ->will($this->throwException($this->getMock($exception, null, array(), '', true))) ; } diff --git a/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/DaoAuthenticationProviderTest.php b/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/DaoAuthenticationProviderTest.php index d5d6067d75..35b14e8f0f 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/DaoAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/DaoAuthenticationProviderTest.php @@ -14,6 +14,7 @@ namespace Symfony\Component\Security\Tests\Core\Authentication\Provider; use Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder; use Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider; +use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase { @@ -37,7 +38,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface'); $userProvider->expects($this->once()) ->method('loadUserByUsername') - ->will($this->throwException($this->getMock('Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException', null, array(), '', false))) + ->will($this->throwException(new UsernameNotFoundException())) ; $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')); @@ -55,7 +56,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface'); $userProvider->expects($this->once()) ->method('loadUserByUsername') - ->will($this->throwException($this->getMock('RuntimeException', null, array(), '', false))) + ->will($this->throwException(new \RuntimeException())) ; $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')); diff --git a/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php b/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php index 8ad4549510..17234b6b9e 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Security\Tests\Core\Authentication\Provider; use Symfony\Component\Security\Core\Authentication\Provider\PreAuthenticatedAuthenticationProvider; +use Symfony\Component\Security\Core\Exception\LockedException; class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_TestCase { @@ -79,7 +80,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); $userChecker->expects($this->once()) ->method('checkPostAuth') - ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\LockedException', null, array(), '', false))) + ->will($this->throwException(new LockedException())) ; $provider = $this->getProvider($user, $userChecker); diff --git a/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/RememberMeAuthenticationProviderTest.php index 5e250e0d07..88eefbbd2a 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/RememberMeAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/RememberMeAuthenticationProviderTest.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Security\Tests\Core\Authentication\Provider; use Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider; -use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken; +use Symfony\Component\Security\Core\Exception\AccountExpiredException; use Symfony\Component\Security\Core\Role\Role; class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase @@ -52,7 +52,7 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); $userChecker->expects($this->once()) ->method('checkPostAuth') - ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '', false))) + ->will($this->throwException(new AccountExpiredException())) ; $provider = $this->getProvider($userChecker); diff --git a/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php b/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php index 22a7e5d1f4..32f5b1083d 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php @@ -11,10 +11,12 @@ namespace Symfony\Component\Security\Tests\Core\Authentication\Provider; -use Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider; +use Symfony\Component\Security\Core\Exception\AccountExpiredException; +use Symfony\Component\Security\Core\Exception\BadCredentialsException; +use Symfony\Component\Security\Core\Exception\CredentialsExpiredException; +use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\SwitchUserRole; -use Symfony\Component\Security\Core\Exception\BadCredentialsException; class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase { @@ -41,7 +43,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $provider = $this->getProvider(false, false); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '', false))) + ->will($this->throwException(new UsernameNotFoundException())) ; $provider->authenticate($this->getSupportedToken()); @@ -55,7 +57,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $provider = $this->getProvider(false, true); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '', false))) + ->will($this->throwException(new UsernameNotFoundException())) ; $provider->authenticate($this->getSupportedToken()); @@ -83,7 +85,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); $userChecker->expects($this->once()) ->method('checkPreAuth') - ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\CredentialsExpiredException', null, array(), '', false))) + ->will($this->throwException(new CredentialsExpiredException())) ; $provider = $this->getProvider($userChecker); @@ -103,7 +105,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); $userChecker->expects($this->once()) ->method('checkPostAuth') - ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '', false))) + ->will($this->throwException(new AccountExpiredException())) ; $provider = $this->getProvider($userChecker); @@ -128,7 +130,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase ; $provider->expects($this->once()) ->method('checkAuthentication') - ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\BadCredentialsException', null, array(), '', false))) + ->will($this->throwException(new BadCredentialsException())) ; $provider->authenticate($this->getSupportedToken()); From 9bdd3d189dafc993fa10c2995372794e04028f77 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 31 Mar 2014 16:43:30 +0200 Subject: [PATCH 18/19] removed APC on the CLI for Travis as it does not work well with PHPUnit and Composer anyway --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5641aadf92..e933fd3084 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ before_script: - travis_retry sudo apt-get install parallel - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so\napc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sudo locale-gen fr_FR.UTF-8 && sudo update-locale From f613caaf5e3314c036b33a45864a8fda73448c09 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 2 Apr 2014 19:09:16 +0200 Subject: [PATCH 19/19] Revert PHPUnit version, revert APC configuration --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e933fd3084..6ec8f1434b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,12 +18,12 @@ before_script: - travis_retry sudo apt-get install parallel - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sudo locale-gen fr_FR.UTF-8 && sudo update-locale - - wget https://phar.phpunit.de/phpunit.phar && chmod +x phpunit.phar && sudo mv phpunit.phar /usr/local/bin/phpunit - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install script: - - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; /usr/local/bin/phpunit --exclude-group tty,benchmark {};' || exit 1 - - echo "Running tests requiring tty"; /usr/local/bin/phpunit --group tty + - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' || exit 1 + - echo "Running tests requiring tty"; phpunit --group tty