diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 8e80c47205..f9f6aabe73 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -14,6 +14,7 @@ namespace Symfony\Component\DependencyInjection\Tests; require_once __DIR__.'/Fixtures/includes/classes.php'; require_once __DIR__.'/Fixtures/includes/ProjectExtension.php'; +use Symfony\Bridge\PhpUnit\ErrorAssert; use Symfony\Component\Config\Resource\ResourceInterface; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -61,27 +62,13 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase public function testCreateDeprecatedService() { - $deprecations = array(); - set_error_handler(function ($type, $msg) use (&$deprecations) { - if (E_USER_DEPRECATED !== $type) { - restore_error_handler(); + ErrorAssert::assertDeprecationsAreTriggered('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', function () { + $definition = new Definition('stdClass'); + $definition->setDeprecated(true); - return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args()); - } - - $deprecations[] = $msg; + $builder = new ContainerBuilder(); + $builder->createService($definition, 'deprecated_foo'); }); - - $definition = new Definition('stdClass'); - $definition->setDeprecated(true); - - $builder = new ContainerBuilder(); - $builder->createService($definition, 'deprecated_foo'); - - restore_error_handler(); - - $this->assertCount(1, $deprecations); - $this->assertContains('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', $deprecations[0]); } public function testRegister() diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 0152e07ffe..7b36819535 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Yaml\Tests; +use Symfony\Bridge\PhpUnit\ErrorAssert; use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Parser; @@ -930,27 +931,14 @@ EOF; */ public function testColonInMappingValueException() { - $yaml = <<parser; + + ErrorAssert::assertDeprecationsAreTriggered('Using a colon in the unquoted mapping value "bar: baz" in line 1 is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', function () use ($parser) { + $yaml = <<parse($yaml); }); - - $this->parser->parse($yaml); - - restore_error_handler(); - - $this->assertCount(1, $deprecations); - $this->assertContains('Using a colon in the unquoted mapping value "bar: baz" in line 1 is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', $deprecations[0]); } public function testColonInMappingValueExceptionNotTriggeredByColonInComment()