diff --git a/.travis.yml b/.travis.yml
index 85a1f7a074..6ec8f1434b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -21,6 +21,7 @@ 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;'
+ - sudo locale-gen fr_FR.UTF-8 && sudo update-locale
- COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install
script:
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/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 %}
Event name |
@@ -52,6 +52,17 @@
{% endfor %}
+ {% 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/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.',
),
);
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)
+ }
}
}
diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
index 0e07ec6b15..da4d7b5776 100644
--- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
@@ -460,51 +460,45 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
{
$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;
}
/**
diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
index 5f0781ebed..23ad9b77e9 100644
--- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
+++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
@@ -142,8 +142,19 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
*/
public function getNotCalledListeners()
{
+ 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));
+ }
+
+ // unable to retrieve the uncalled listeners
+ return array();
+ }
+
$notCalled = array();
- foreach ($this->getListeners() as $eventName => $listeners) {
+ foreach ($allListeners as $eventName => $listeners) {
foreach ($listeners as $listener) {
$called = false;
if (isset($this->called[$eventName])) {
diff --git a/src/Symfony/Component/Form/Button.php b/src/Symfony/Component/Form/Button.php
index 2fd9306f30..47235e23e2 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;
}
/**
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/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
index cdaee86b25..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 = hash('sha256', 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']);
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/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php
index 3da49dfa6a..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());
@@ -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');
diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
index 528114257a..11b616b1b3 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()
diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
index 3ab1b0d92a..739687e6d1 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) {
diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php
index ae59864087..a137d73097 100644
--- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php
+++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php
@@ -780,7 +780,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()
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
diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
index f83b9ecba8..e6c80290e1 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
@@ -64,7 +64,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'));
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
index b053d73b8f..f63ef79c2d 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/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/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
index 3e285d7641..ae96f1097a 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
@@ -14,6 +14,7 @@ namespace Symfony\Component\Security\Core\Tests\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/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
index 4a8bf6cb16..5fd7b05ef0 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Core\Tests\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/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
index 43da274d5b..d278ba45fe 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
@@ -12,7 +12,7 @@
namespace Symfony\Component\Security\Core\Tests\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/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
index db47589987..05030543e6 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
@@ -11,10 +11,12 @@
namespace Symfony\Component\Security\Core\Tests\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());
diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php
index 764678c299..a7906e6247 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.☎/'),
);
}