|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\DependencyInjection\Tests;
|
13 | 13 |
|
14 |
| -use Symfony\Bridge\PhpUnit\ErrorAssert; |
15 | 14 | use Symfony\Component\DependencyInjection\Container;
|
16 | 15 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
17 | 16 | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
@@ -131,20 +130,14 @@ public function testGetServiceIds()
|
131 | 130 |
|
132 | 131 | /**
|
133 | 132 | * @group legacy
|
134 |
| - * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered |
| 133 | + * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map. |
135 | 134 | */
|
136 | 135 | public function testGetLegacyServiceIds()
|
137 | 136 | {
|
138 | 137 | $sc = new LegacyProjectServiceContainer();
|
139 | 138 | $sc->set('foo', $obj = new \stdClass());
|
140 | 139 |
|
141 |
| - $deprecations = array( |
142 |
| - 'Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', |
143 |
| - ); |
144 |
| - |
145 |
| - ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () use ($sc) { |
146 |
| - $this->assertEquals(array('internal', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'service_container', 'foo'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods, followed by service ids defined by set()'); |
147 |
| - }); |
| 140 | + $this->assertEquals(array('internal', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'service_container', 'foo'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods, followed by service ids defined by set()'); |
148 | 141 | }
|
149 | 142 |
|
150 | 143 | public function testSet()
|
@@ -193,39 +186,33 @@ public function testGet()
|
193 | 186 |
|
194 | 187 | /**
|
195 | 188 | * @group legacy
|
196 |
| - * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered |
| 189 | + * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map. |
| 190 | + * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map. |
| 191 | + * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map. |
| 192 | + * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map. |
197 | 193 | */
|
198 | 194 | public function testLegacyGet()
|
199 | 195 | {
|
200 | 196 | $sc = new LegacyProjectServiceContainer();
|
201 | 197 | $sc->set('foo', $foo = new \stdClass());
|
202 | 198 |
|
203 |
| - $deprecations = array( |
204 |
| - 'Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', |
205 |
| - 'Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', |
206 |
| - 'Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', |
207 |
| - 'Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', |
208 |
| - ); |
209 |
| - |
210 |
| - ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () use ($sc, $foo) { |
211 |
| - $this->assertEquals($foo, $sc->get('foo'), '->get() returns the service for the given id'); |
212 |
| - $this->assertEquals($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase'); |
213 |
| - $this->assertEquals($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id'); |
214 |
| - $this->assertEquals($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined'); |
215 |
| - $this->assertEquals($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined'); |
216 |
| - $this->assertEquals($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined'); |
| 199 | + $this->assertEquals($foo, $sc->get('foo'), '->get() returns the service for the given id'); |
| 200 | + $this->assertEquals($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase'); |
| 201 | + $this->assertEquals($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id'); |
| 202 | + $this->assertEquals($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined'); |
| 203 | + $this->assertEquals($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined'); |
| 204 | + $this->assertEquals($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined'); |
217 | 205 |
|
218 |
| - $sc->set('bar', $bar = new \stdClass()); |
219 |
| - $this->assertEquals($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()'); |
| 206 | + $sc->set('bar', $bar = new \stdClass()); |
| 207 | + $this->assertEquals($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()'); |
220 | 208 |
|
221 |
| - try { |
222 |
| - $sc->get(''); |
223 |
| - $this->fail('->get() throws a \InvalidArgumentException exception if the service is empty'); |
224 |
| - } catch (\Exception $e) { |
225 |
| - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws a ServiceNotFoundException exception if the service is empty'); |
226 |
| - } |
227 |
| - $this->assertNull($sc->get('', ContainerInterface::NULL_ON_INVALID_REFERENCE), '->get() returns null if the service is empty'); |
228 |
| - }); |
| 209 | + try { |
| 210 | + $sc->get(''); |
| 211 | + $this->fail('->get() throws a \InvalidArgumentException exception if the service is empty'); |
| 212 | + } catch (\Exception $e) { |
| 213 | + $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws a ServiceNotFoundException exception if the service is empty'); |
| 214 | + } |
| 215 | + $this->assertNull($sc->get('', ContainerInterface::NULL_ON_INVALID_REFERENCE), '->get() returns null if the service is empty'); |
229 | 216 | }
|
230 | 217 |
|
231 | 218 | public function testGetThrowServiceNotFoundException()
|
@@ -288,28 +275,22 @@ public function testHas()
|
288 | 275 |
|
289 | 276 | /**
|
290 | 277 | * @group legacy
|
291 |
| - * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered |
| 278 | + * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map. |
| 279 | + * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map. |
| 280 | + * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map. |
| 281 | + * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map. |
292 | 282 | */
|
293 | 283 | public function testLegacyHas()
|
294 | 284 | {
|
295 | 285 | $sc = new LegacyProjectServiceContainer();
|
296 | 286 | $sc->set('foo', new \stdClass());
|
297 | 287 |
|
298 |
| - $deprecations = array( |
299 |
| - 'Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', |
300 |
| - 'Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', |
301 |
| - 'Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', |
302 |
| - 'Generating a dumped container without populating the method map is deprecated since 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.', |
303 |
| - ); |
304 |
| - |
305 |
| - ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () use ($sc) { |
306 |
| - $this->assertFalse($sc->has('foo1'), '->has() returns false if the service does not exist'); |
307 |
| - $this->assertTrue($sc->has('foo'), '->has() returns true if the service exists'); |
308 |
| - $this->assertTrue($sc->has('bar'), '->has() returns true if a get*Method() is defined'); |
309 |
| - $this->assertTrue($sc->has('foo_bar'), '->has() returns true if a get*Method() is defined'); |
310 |
| - $this->assertTrue($sc->has('foo.baz'), '->has() returns true if a get*Method() is defined'); |
311 |
| - $this->assertTrue($sc->has('foo\\baz'), '->has() returns true if a get*Method() is defined'); |
312 |
| - }); |
| 288 | + $this->assertFalse($sc->has('foo1'), '->has() returns false if the service does not exist'); |
| 289 | + $this->assertTrue($sc->has('foo'), '->has() returns true if the service exists'); |
| 290 | + $this->assertTrue($sc->has('bar'), '->has() returns true if a get*Method() is defined'); |
| 291 | + $this->assertTrue($sc->has('foo_bar'), '->has() returns true if a get*Method() is defined'); |
| 292 | + $this->assertTrue($sc->has('foo.baz'), '->has() returns true if a get*Method() is defined'); |
| 293 | + $this->assertTrue($sc->has('foo\\baz'), '->has() returns true if a get*Method() is defined'); |
313 | 294 | }
|
314 | 295 |
|
315 | 296 | public function testInitialized()
|
@@ -400,66 +381,42 @@ public function testThatCloningIsNotSupported()
|
400 | 381 |
|
401 | 382 | /**
|
402 | 383 | * @group legacy
|
403 |
| - * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered |
| 384 | + * @expectedDeprecation Unsetting the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. |
404 | 385 | */
|
405 | 386 | public function testUnsetInternalPrivateServiceIsDeprecated()
|
406 | 387 | {
|
407 |
| - $deprecations = array( |
408 |
| - 'Unsetting the "internal" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', |
409 |
| - ); |
410 |
| - |
411 |
| - ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () { |
412 |
| - $c = new ProjectServiceContainer(); |
413 |
| - $c->set('internal', null); |
414 |
| - }); |
| 388 | + $c = new ProjectServiceContainer(); |
| 389 | + $c->set('internal', null); |
415 | 390 | }
|
416 | 391 |
|
417 | 392 | /**
|
418 | 393 | * @group legacy
|
419 |
| - * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered |
| 394 | + * @expectedDeprecation Setting the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. A new public service will be created instead. |
420 | 395 | */
|
421 | 396 | public function testChangeInternalPrivateServiceIsDeprecated()
|
422 | 397 | {
|
423 |
| - $deprecations = array( |
424 |
| - 'Setting the "internal" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0. A new public service will be created instead.', |
425 |
| - ); |
426 |
| - |
427 |
| - ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () { |
428 |
| - $c = new ProjectServiceContainer(); |
429 |
| - $c->set('internal', new \stdClass()); |
430 |
| - }); |
| 398 | + $c = new ProjectServiceContainer(); |
| 399 | + $c->set('internal', new \stdClass()); |
431 | 400 | }
|
432 | 401 |
|
433 | 402 | /**
|
434 | 403 | * @group legacy
|
435 |
| - * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered |
| 404 | + * @expectedDeprecation Checking for the existence of the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. |
436 | 405 | */
|
437 | 406 | public function testCheckExistenceOfAnInternalPrivateServiceIsDeprecated()
|
438 | 407 | {
|
439 |
| - $deprecations = array( |
440 |
| - 'Checking for the existence of the "internal" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', |
441 |
| - ); |
442 |
| - |
443 |
| - ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () { |
444 |
| - $c = new ProjectServiceContainer(); |
445 |
| - $c->has('internal'); |
446 |
| - }); |
| 408 | + $c = new ProjectServiceContainer(); |
| 409 | + $c->has('internal'); |
447 | 410 | }
|
448 | 411 |
|
449 | 412 | /**
|
450 | 413 | * @group legacy
|
451 |
| - * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered |
| 414 | + * @expectedDeprecation Requesting the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. |
452 | 415 | */
|
453 | 416 | public function testRequestAnInternalSharedPrivateServiceIsDeprecated()
|
454 | 417 | {
|
455 |
| - $deprecations = array( |
456 |
| - 'Requesting the "internal" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', |
457 |
| - ); |
458 |
| - |
459 |
| - ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () { |
460 |
| - $c = new ProjectServiceContainer(); |
461 |
| - $c->get('internal'); |
462 |
| - }); |
| 418 | + $c = new ProjectServiceContainer(); |
| 419 | + $c->get('internal'); |
463 | 420 | }
|
464 | 421 | }
|
465 | 422 |
|
|
0 commit comments