|
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;
|
20 | 21 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
21 | 22 | use Symfony\Component\DependencyInjection\Definition;
|
22 | 23 | use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
23 |
| -use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; |
24 | 24 | use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
|
25 | 25 | use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
26 | 26 | use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
|
@@ -60,28 +60,14 @@ public function testDefinitions()
|
60 | 60 |
|
61 | 61 | public function testCreateDeprecatedService()
|
62 | 62 | {
|
63 |
| - $deprecations = array(); |
64 |
| - set_error_handler(function ($type, $msg) use (&$deprecations) { |
65 |
| - if (E_USER_DEPRECATED !== $type) { |
66 |
| - restore_error_handler(); |
| 63 | + ErrorAssert::assertDeprecationsAreTriggered('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', function () { |
| 64 | + $definition = new Definition('stdClass'); |
| 65 | + $definition->setDeprecated(true); |
67 | 66 |
|
68 |
| - return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args()); |
69 |
| - } |
70 |
| - |
71 |
| - $deprecations[] = $msg; |
| 67 | + $builder = new ContainerBuilder(); |
| 68 | + $builder->setDefinition('deprecated_foo', $definition); |
| 69 | + $builder->get('deprecated_foo'); |
72 | 70 | });
|
73 |
| - |
74 |
| - $definition = new Definition('stdClass'); |
75 |
| - $definition->setDeprecated(true); |
76 |
| - |
77 |
| - $builder = new ContainerBuilder(); |
78 |
| - $builder->setDefinition('deprecated_foo', $definition); |
79 |
| - $builder->get('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 | 71 | }
|
86 | 72 |
|
87 | 73 | public function testRegister()
|
|
0 commit comments