|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\DependencyInjection\Tests\Loader; |
13 | 13 |
|
| 14 | +use Symfony\Bridge\PhpUnit\ErrorAssert; |
14 | 15 | use Symfony\Component\DependencyInjection\ContainerInterface; |
15 | 16 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
16 | 17 | use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; |
@@ -546,29 +547,19 @@ public function testAutowire() |
546 | 547 | */ |
547 | 548 | public function testAliasDefinitionContainsUnsupportedElements() |
548 | 549 | { |
549 | | - $container = new ContainerBuilder(); |
550 | | - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); |
| 550 | + $deprecations = array( |
| 551 | + 'Using the attribute "class" is deprecated for alias definition "bar"', |
| 552 | + 'Using the element "tag" is deprecated for alias definition "bar"', |
| 553 | + 'Using the element "factory" is deprecated for alias definition "bar"', |
| 554 | + ); |
551 | 555 |
|
552 | | - $deprecations = array(); |
553 | | - set_error_handler(function ($type, $msg) use (&$deprecations) { |
554 | | - if (E_USER_DEPRECATED !== $type) { |
555 | | - restore_error_handler(); |
| 556 | + ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () { |
| 557 | + $container = new ContainerBuilder(); |
| 558 | + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); |
556 | 559 |
|
557 | | - return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args()); |
558 | | - } |
| 560 | + $loader->load('legacy_invalid_alias_definition.xml'); |
559 | 561 |
|
560 | | - $deprecations[] = $msg; |
| 562 | + $this->assertTrue($container->has('bar')); |
561 | 563 | }); |
562 | | - |
563 | | - $loader->load('legacy_invalid_alias_definition.xml'); |
564 | | - |
565 | | - restore_error_handler(); |
566 | | - |
567 | | - $this->assertTrue($container->has('bar')); |
568 | | - |
569 | | - $this->assertCount(3, $deprecations); |
570 | | - $this->assertContains('Using the attribute "class" is deprecated for alias definition "bar"', $deprecations[0]); |
571 | | - $this->assertContains('Using the element "tag" is deprecated for alias definition "bar"', $deprecations[1]); |
572 | | - $this->assertContains('Using the element "factory" is deprecated for alias definition "bar"', $deprecations[2]); |
573 | 564 | } |
574 | 565 | } |
0 commit comments