|
14 | 14 | require_once __DIR__.'/Fixtures/includes/classes.php';
|
15 | 15 | require_once __DIR__.'/Fixtures/includes/ProjectExtension.php';
|
16 | 16 |
|
| 17 | +use Symfony\Bridge\PhpUnit\ErrorAssert; |
17 | 18 | use Symfony\Component\Config\Resource\ResourceInterface;
|
18 | 19 | use Symfony\Component\DependencyInjection\Alias;
|
19 | 20 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
@@ -61,27 +62,13 @@ public function testDefinitions()
|
61 | 62 |
|
62 | 63 | public function testCreateDeprecatedService()
|
63 | 64 | {
|
64 |
| - $deprecations = array(); |
65 |
| - set_error_handler(function ($type, $msg) use (&$deprecations) { |
66 |
| - if (E_USER_DEPRECATED !== $type) { |
67 |
| - restore_error_handler(); |
| 65 | + ErrorAssert::assertDeprecationsAreTriggered('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', function () { |
| 66 | + $definition = new Definition('stdClass'); |
| 67 | + $definition->setDeprecated(true); |
68 | 68 |
|
69 |
| - return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args()); |
70 |
| - } |
71 |
| - |
72 |
| - $deprecations[] = $msg; |
| 69 | + $builder = new ContainerBuilder(); |
| 70 | + $builder->createService($definition, 'deprecated_foo'); |
73 | 71 | });
|
74 |
| - |
75 |
| - $definition = new Definition('stdClass'); |
76 |
| - $definition->setDeprecated(true); |
77 |
| - |
78 |
| - $builder = new ContainerBuilder(); |
79 |
| - $builder->createService($definition, 'deprecated_foo'); |
80 |
| - |
81 |
| - restore_error_handler(); |
82 |
| - |
83 |
| - $this->assertCount(1, $deprecations); |
84 |
| - $this->assertContains('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', $deprecations[0]); |
85 | 72 | }
|
86 | 73 |
|
87 | 74 | public function testRegister()
|
|
0 commit comments