From 2e241cc606d1362698cef86a10791787bbd6545c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B3th=20G=C3=A1bor?= Date: Mon, 2 Dec 2013 15:32:33 +0100 Subject: [PATCH 01/13] [HttpKernel] use static late binding when dumping out container --- src/Symfony/Component/HttpKernel/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 200d9de294..6ffa4e3e11 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -690,7 +690,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface $dumper = new PhpDumper($container); $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass)); if (!$this->debug) { - $content = self::stripComments($content); + $content = static::stripComments($content); } $cache->write($content, $container->getResources()); From 8209a7f95b9d233a0eb3b3d4e4bdf638bed515e8 Mon Sep 17 00:00:00 2001 From: Christian Raue Date: Tue, 3 Dec 2013 11:59:03 +0100 Subject: [PATCH 02/13] fixed typos in several translations --- .../Component/Form/Resources/translations/validators.es.xlf | 2 +- .../Component/Form/Resources/translations/validators.gl.xlf | 2 +- .../Component/Form/Resources/translations/validators.ja.xlf | 6 +++--- .../Validator/Resources/translations/validators.ar.xlf | 4 ++-- .../Validator/Resources/translations/validators.cy.xlf | 2 +- .../Validator/Resources/translations/validators.id.xlf | 2 +- .../Validator/Resources/translations/validators.no.xlf | 2 +- .../Validator/Resources/translations/validators.pt_BR.xlf | 2 +- .../Validator/Resources/translations/validators.ru.xlf | 2 +- .../Validator/Resources/translations/validators.tr.xlf | 6 +++--- .../Validator/Resources/translations/validators.uk.xlf | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/Form/Resources/translations/validators.es.xlf b/src/Symfony/Component/Form/Resources/translations/validators.es.xlf index ebfacfd487..175096ae8a 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.es.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.es.xlf @@ -12,7 +12,7 @@ The CSRF token is invalid. Please try to resubmit the form. - El token CSRF no es válido. Por favor, pruebe de enviar nuevamente el formulario + El token CSRF no es válido. Por favor, pruebe de enviar nuevamente el formulario. diff --git a/src/Symfony/Component/Form/Resources/translations/validators.gl.xlf b/src/Symfony/Component/Form/Resources/translations/validators.gl.xlf index db23fe2be6..88cc6536ea 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.gl.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.gl.xlf @@ -12,7 +12,7 @@ The CSRF token is invalid. Please try to resubmit the form. - O token CSRF non é válido. Por favor, probe a enviar novamente o formulario + O token CSRF non é válido. Por favor, probe a enviar novamente o formulario. diff --git a/src/Symfony/Component/Form/Resources/translations/validators.ja.xlf b/src/Symfony/Component/Form/Resources/translations/validators.ja.xlf index 4559af1769..2e8585a75c 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.ja.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.ja.xlf @@ -4,15 +4,15 @@ This form should not contain extra fields. - フィールドグループに追加のフィールドを含んではなりません. + フィールドグループに追加のフィールドを含んではなりません。 The uploaded file was too large. Please try to upload a smaller file. - アップロードされたファイルが大きすぎます。小さなファイルで再度アップロードしてください. + アップロードされたファイルが大きすぎます。小さなファイルで再度アップロードしてください。 The CSRF token is invalid. - CSRFトークンが無効です. + CSRFトークンが無効です。 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf index 4e92a9fe92..7a54231147 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf @@ -80,7 +80,7 @@ This value should be {{ limit }} or more. - هذه القيمة يجب ان تكون {{ limit }} او اكثر + هذه القيمة يجب ان تكون {{ limit }} او اكثر. This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. @@ -104,7 +104,7 @@ This value is not a valid time. - هذه القيمة ليست وقت صحيح + هذه القيمة ليست وقت صحيح. This value is not a valid URL. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf index e6e7a86266..79e8e5c8eb 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf @@ -124,7 +124,7 @@ The file could not be uploaded. - Methwyd � uwchlwytho'r ffeil. + Methwyd � uwchlwytho'r ffeil. This value should be a valid number. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf index 816489f7a1..4e8faf50aa 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf @@ -192,7 +192,7 @@ No temporary folder was configured in php.ini. - Direktori sementara tidak dikonfiguasi pada php.ini + Direktori sementara tidak dikonfiguasi pada php.ini. Cannot write temporary file to disk. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf index 51d0cae142..eeebabab24 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf @@ -4,7 +4,7 @@ This value should be false. - Verdien skulle ha vore tom/nei + Verdien skulle ha vore tom/nei. This value should be true. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf index 075ab28ca4..fbe58f0209 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf @@ -24,7 +24,7 @@ You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - Você deve selecionar, no mínimo, {{ limit }} opção.|Você deve selecionar, no mínimo, {{ limit }} opções + Você deve selecionar, no mínimo, {{ limit }} opção.|Você deve selecionar, no mínimo, {{ limit }} opções. You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf index 7c6270015c..6205891ce3 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf @@ -236,7 +236,7 @@ This value is neither a valid ISBN-10 nor a valid ISBN-13. - Значение не соответствует форматам ISBN-10 и ISBN-13 + Значение не соответствует форматам ISBN-10 и ISBN-13. This value is not a valid ISSN. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf index d2f3984fed..45c6a2afa8 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf @@ -204,15 +204,15 @@ This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. - Bu derlem {{ limit }} veya daha çok eleman içermelidir + Bu derlem {{ limit }} veya daha çok eleman içermelidir. This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. - Bu derlem {{ limit }} veya daha az eleman içermelidir + Bu derlem {{ limit }} veya daha az eleman içermelidir. This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. - Bu derlem {{ limit }} eleman içermelidir + Bu derlem {{ limit }} eleman içermelidir. Invalid card number. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf index ad1c430c4e..1832b34a01 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf @@ -28,7 +28,7 @@ You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. - Ви повинні обрати не більше ніж {{ limit }} варіантів + Ви повинні обрати не більше ніж {{ limit }} варіантів. One or more of the given values is invalid. From 578476280845ea18ac5cea8fe56563d66741f119 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 3 Dec 2013 16:21:41 +0100 Subject: [PATCH 03/13] updated CHANGELOG for 2.4.0 --- CHANGELOG-2.4.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CHANGELOG-2.4.md b/CHANGELOG-2.4.md index c27e2a931a..e3dbd537bd 100644 --- a/CHANGELOG-2.4.md +++ b/CHANGELOG-2.4.md @@ -7,6 +7,28 @@ in 2.4 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.4.0...v2.4.1 +* 2.4.0 (2013-12-03) + + * bug #9673 Fixed BC break in csrf protection (WouterJ) + * bug #9665 [Bridge/Doctrine] ORMQueryBuilderLoader - handled the scenario when no entity manager is passed with closure query builder (jakzal) + * bug #9662 [FrameworkBundle] Enabled csrf_protection by default if form.csrf_protection is enabled (bschussek) + * bug #9656 [DoctrineBridge] normalized class names in the ORM type guesser (fabpot) + * bug #9647 use the correct class name to retrieve mapped class' metadata and reposi... (xabbuh) + * bug #9648 [Debug] ensured that a fatal PHP error is actually fatal after being handled by our error handler (fabpot) + * bug #9643 [WebProfilerBundle] Fixed js escaping in time.html.twig (hason) + * bug #9641 [Debug] Avoid notice from being "eaten" by fatal error. (fabpot) + * bug #9639 Modified guessDefaultEscapingStrategy to not escape txt templates (fabpot) + * bug #9314 [Form] Fix DateType for 32bits computers. (WedgeSama) + * bug #9443 [FrameworkBundle] Fixed the registration of validation.xml file when the form is disabled (hason) + * bug #9625 [HttpFoundation] Do not return an empty session id if the session was closed (Taluu) + * bug #9621 [ExpressionLanguage] fixed lexing expression ending with spaces (fabpot) + * bug #9637 [Validator] Replaced inexistent interface (jakzal) + * bug #9628 [HttpKernel] Fix profiler event-listener usage outside request stack context (romainneutron) + * bug #9624 [Console] Fix undefined offset when formatting namespace suggestions (GromNaN) + * bug #9605 Adjusting CacheClear Warmup method to namespaced kernels (rdohms) + * bug #9617 [HttpKernel] Http kernel regression fix (hhamon) + * bug #9610 Container::camelize also takes backslashes into consideration (ondrejmirtes) + * 2.4.0-RC1 (2013-11-25) * bug #9607 [HttpKernel] Fix a bug when using the kernel property in overridden method Client::setServerParameters() (gnutix) From 2e47d2edd45080c046bc32dd2ca5c64f31086366 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 3 Dec 2013 16:23:03 +0100 Subject: [PATCH 04/13] updated VERSION for 2.4.0 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 609b650b35..4be3041cec 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -60,12 +60,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.4.0-DEV'; + const VERSION = '2.4.0'; const VERSION_ID = '20400'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '4'; const RELEASE_VERSION = '0'; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; /** * Constructor. From a20b9a410317bb70d97854943197081867490da5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 3 Dec 2013 18:55:28 +0100 Subject: [PATCH 05/13] bumped Symfony version to 2.4.1 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 4be3041cec..bf98d0c794 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -60,12 +60,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.4.0'; - const VERSION_ID = '20400'; + const VERSION = '2.4.1-DEV'; + const VERSION_ID = '20401'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '4'; - const RELEASE_VERSION = '0'; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = '1'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From a36abaf1b55772fa2317ab8bf93dd722e9a7f9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=A4rtner?= Date: Tue, 3 Dec 2013 20:56:02 +0100 Subject: [PATCH 06/13] Switched to correct gender of "Token" The neutral gender "das Token" is used in science to describe an array of bits or chars, where as the masculin "der Token" is commenly used for keys in communications and authentication in the network. I guess the a CSRF-Token is more a key for authentication then a bit array. --- .../Component/Form/Resources/translations/validators.de.xlf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Form/Resources/translations/validators.de.xlf b/src/Symfony/Component/Form/Resources/translations/validators.de.xlf index c801d67706..a9a183197e 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.de.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.de.xlf @@ -12,8 +12,8 @@ The CSRF token is invalid. Please try to resubmit the form. - Das CSRF-Token ist ungültig. Versuchen Sie bitte das Formular erneut zu senden. + Der CSRF-Token ist ungültig. Versuchen Sie bitte das Formular erneut zu senden. - \ No newline at end of file + From 8d53d8f2c005984cce2f2a4d077e058d32e79749 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Wed, 4 Dec 2013 13:44:44 -0500 Subject: [PATCH 07/13] raising delta on stopwatch as travis really breaks with less than 35 --- src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php index cd7b8d4eae..af63153382 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php @@ -20,7 +20,7 @@ use Symfony\Component\Stopwatch\StopwatchEvent; */ class StopwatchEventTest extends \PHPUnit_Framework_TestCase { - const DELTA = 20; + const DELTA = 37; public function testGetOrigin() { From 955e8cf084329a2f38d43b15ccb0031bd2174c3c Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 5 Dec 2013 23:38:14 +0000 Subject: [PATCH 08/13] [FrameworkBundle] Allowed "0" as a checkbox value in the php template. --- .../Resources/views/Form/checkbox_widget.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/checkbox_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/checkbox_widget.html.php index d3cf747353..143557dea8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/checkbox_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/checkbox_widget.html.php @@ -1,5 +1,5 @@ block($form, 'widget_attributes') ?> - value="escape($value) ?>" + 0): ?> value="escape($value) ?>" checked="checked" /> From ae95a718c3779aaeb8aeab409ba5df1a58b0536a Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 6 Dec 2013 14:19:14 +0100 Subject: [PATCH 09/13] Reset the box model to content-box in the web debug toolbar This makes the styles compatible with CSS frameworks changing the box model to box-sizing using a universal selector (Bootstrap 3 for instance). --- .../Resources/views/Profiler/toolbar.css.twig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig index 7d42db642b..f7f8e8cf97 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -18,6 +18,12 @@ z-index: 6000000; } +.sf-toolbarreset * { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} + .sf-toolbarreset { position: fixed; background-color: #f7f7f7; From fc232a5d9aba5161d570db714e6c5a934ad36929 Mon Sep 17 00:00:00 2001 From: Ait boudad Abdellatif Date: Fri, 6 Dec 2013 20:29:27 +0000 Subject: [PATCH 10/13] [validator] throw an exception if isn't an instance of ConstraintValidatorInterface. --- .../Validator/ConstraintValidatorFactoryTest.php | 2 +- .../Validator/ConstraintValidatorFactory.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php index 7dc3389939..efdff8197b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php @@ -43,7 +43,7 @@ class ConstraintValidatorFactoryTest extends \PHPUnit_Framework_TestCase { $service = 'validator_constraint_service'; $alias = 'validator_constraint_alias'; - $validator = new \stdClass(); + $validator = $this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintValidator'); // mock ContainerBuilder b/c it implements TaggedContainerInterface $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerBuilder'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Validator/ConstraintValidatorFactory.php b/src/Symfony/Bundle/FrameworkBundle/Validator/ConstraintValidatorFactory.php index 86e2f99454..66f0d012d3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Validator/ConstraintValidatorFactory.php +++ b/src/Symfony/Bundle/FrameworkBundle/Validator/ConstraintValidatorFactory.php @@ -14,7 +14,8 @@ namespace Symfony\Bundle\FrameworkBundle\Validator; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; -use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\ConstraintValidatorInterface; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * Uses a service container to create constraint validators. @@ -58,7 +59,9 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface * * @param Constraint $constraint A constraint * - * @return ConstraintValidator A validator for the supplied constraint + * @return ConstraintValidatorInterface A validator for the supplied constraint + * + * @throws UnexpectedTypeException When the validator is not an instance of ConstraintValidatorInterface */ public function getInstance(Constraint $constraint) { @@ -70,6 +73,10 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface $this->validators[$name] = $this->container->get($this->validators[$name]); } + if (!$this->validators[$name] instanceof ConstraintValidatorInterface) { + throw new UnexpectedTypeException($this->validators[$name], 'Symfony\Component\Validator\ConstraintValidatorInterface'); + } + return $this->validators[$name]; } } From 113831ef11b628f0ee532f082429b7c778e6d28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Concei=C3=A7=C3=A3o?= Date: Tue, 10 Dec 2013 14:47:08 +0000 Subject: [PATCH 11/13] Fixed typo --- .../Validator/Resources/translations/validators.pt.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf index cd5ac236e3..354ecc6cc9 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf @@ -132,7 +132,7 @@ This file is not a valid image. - Este ficheito não é uma imagem. + Este ficheiro não é uma imagem. This is not a valid IP address. From a259c048f4cd358d24a997118251b43420a5cd45 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 11 Dec 2013 16:16:31 +0100 Subject: [PATCH 12/13] ErrorHandlerTest: restore_error_handler() on assertion failure --- .../Debug/Tests/ErrorHandlerTest.php | 135 ++++++++++-------- 1 file changed, 78 insertions(+), 57 deletions(-) diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 2f71fc6b66..45eb38a2ea 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -90,6 +90,11 @@ PHP ); } catch (DummyException $e) { // if an exception is thrown, the test passed + } catch (\Exception $e) { + restore_error_handler(); + restore_exception_handler(); + + throw $e; } restore_error_handler(); @@ -135,6 +140,10 @@ PHP self::triggerNotice($this); } catch (DummyException $e) { // if an exception is thrown, the test passed + } catch (\Exception $e) { + restore_error_handler(); + + throw $e; } restore_error_handler(); @@ -150,72 +159,84 @@ PHP public function testConstruct() { - $handler = ErrorHandler::register(3); + try { + $handler = ErrorHandler::register(3); - $level = new \ReflectionProperty($handler, 'level'); - $level->setAccessible(true); + $level = new \ReflectionProperty($handler, 'level'); + $level->setAccessible(true); - $this->assertEquals(3, $level->getValue($handler)); + $this->assertEquals(3, $level->getValue($handler)); - restore_error_handler(); + restore_error_handler(); + } catch (\Exception $e) { + restore_error_handler(); + + throw $e; + } } public function testHandle() { - $handler = ErrorHandler::register(0); - $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, 'foo')); - - restore_error_handler(); - - $handler = ErrorHandler::register(3); - $this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, 'foo')); - - restore_error_handler(); - - $handler = ErrorHandler::register(3); try { - $handler->handle(111, 'foo', 'foo.php', 12, 'foo'); - } catch (\ErrorException $e) { - $this->assertSame('111: foo in foo.php line 12', $e->getMessage()); - $this->assertSame(111, $e->getSeverity()); - $this->assertSame('foo.php', $e->getFile()); - $this->assertSame(12, $e->getLine()); + $handler = ErrorHandler::register(0); + $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, 'foo')); + + restore_error_handler(); + + $handler = ErrorHandler::register(3); + $this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, 'foo')); + + restore_error_handler(); + + $handler = ErrorHandler::register(3); + try { + $handler->handle(111, 'foo', 'foo.php', 12, 'foo'); + } catch (\ErrorException $e) { + $this->assertSame('111: foo in foo.php line 12', $e->getMessage()); + $this->assertSame(111, $e->getSeverity()); + $this->assertSame('foo.php', $e->getFile()); + $this->assertSame(12, $e->getLine()); + } + + restore_error_handler(); + + $handler = ErrorHandler::register(E_USER_DEPRECATED); + $this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo')); + + restore_error_handler(); + + $handler = ErrorHandler::register(E_DEPRECATED); + $this->assertTrue($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, 'foo')); + + restore_error_handler(); + + $logger = $this->getMock('Psr\Log\LoggerInterface'); + + $that = $this; + $warnArgCheck = function($message, $context) use ($that) { + $that->assertEquals('foo', $message); + $that->assertArrayHasKey('type', $context); + $that->assertEquals($context['type'], ErrorHandler::TYPE_DEPRECATION); + $that->assertArrayHasKey('stack', $context); + $that->assertInternalType('array', $context['stack']); + }; + + $logger + ->expects($this->once()) + ->method('warning') + ->will($this->returnCallback($warnArgCheck)) + ; + + $handler = ErrorHandler::register(E_USER_DEPRECATED); + $handler->setLogger($logger); + $handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo'); + + restore_error_handler(); + } catch (\Exception $e) { + restore_error_handler(); + + throw $e; } - - restore_error_handler(); - - $handler = ErrorHandler::register(E_USER_DEPRECATED); - $this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo')); - - restore_error_handler(); - - $handler = ErrorHandler::register(E_DEPRECATED); - $this->assertTrue($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, 'foo')); - - restore_error_handler(); - - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $that = $this; - $warnArgCheck = function($message, $context) use ($that) { - $that->assertEquals('foo', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], ErrorHandler::TYPE_DEPRECATION); - $that->assertArrayHasKey('stack', $context); - $that->assertInternalType('array', $context['stack']); - }; - - $logger - ->expects($this->once()) - ->method('warning') - ->will($this->returnCallback($warnArgCheck)) - ; - - $handler = ErrorHandler::register(E_USER_DEPRECATED); - $handler->setLogger($logger); - $handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo'); - - restore_error_handler(); } /** From 5f7cec1e38cba68c2ad0546ac5bcc8c0d135bf94 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 12 Dec 2013 17:06:35 +0100 Subject: [PATCH 13/13] [Debug] fixed tests --- .../Component/Debug/Tests/ErrorHandlerTest.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 45eb38a2ea..fdae5fe6e2 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -110,7 +110,7 @@ PHP $exceptionCheck = function($exception) use ($that) { $that->assertInstanceOf('Symfony\Component\Debug\Exception\ContextErrorException', $exception); $that->assertEquals(E_NOTICE, $exception->getSeverity()); - $that->assertEquals(__LINE__ + 40, $exception->getLine()); + $that->assertEquals(__LINE__ + 44, $exception->getLine()); $that->assertEquals(__FILE__, $exception->getFile()); $that->assertRegexp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); $that->assertArrayHasKey('foobar', $exception->getContext()); @@ -267,10 +267,10 @@ PHP 'type' => 1, 'line' => 12, 'file' => 'foo.php', - 'message' => 'Call to undefined function test_namespaced_function()', + 'message' => 'Call to undefined function test_namespaced_function_again()', ), 'Symfony\Component\Debug\Exception\UndefinedFunctionException', - 'Attempted to call function "test_namespaced_function" from the global namespace in foo.php line 12. Did you mean to call: "\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function"?', + 'Attempted to call function "test_namespaced_function_again" from the global namespace in foo.php line 12. Did you mean to call: "\\symfony\\component\\debug\\tests\\test_namespaced_function_again"?', ), // class not found array( @@ -286,3 +286,8 @@ PHP ); } } + + +function test_namespaced_function_again() +{ +}