Skip to content

Commit 9ad474e

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Testing] use static::getContainer() Minor - Remove deprecated self::$container
2 parents 83a393d + cdb16f9 commit 9ad474e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

messenger.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ during a request::
14791479
$this->assertSame(200, $client->getResponse()->getStatusCode());
14801480

14811481
/* @var InMemoryTransport $transport */
1482-
$transport = self::$container->get('messenger.transport.async_priority_normal');
1482+
$transport = $this->getContainer()->get('messenger.transport.async_priority_normal');
14831483
$this->assertCount(1, $transport->getSent());
14841484
}
14851485
}

testing.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Retrieving Services in the Test
246246

247247
In your integration tests, you often need to fetch the service from the
248248
service container to call a specific method. After booting the kernel,
249-
the container is stored in ``self::$container``::
249+
the container is stored in ``static::getContainer()``::
250250

251251
// tests/Service/NewsletterGeneratorTest.php
252252
namespace App\Tests\Service;
@@ -261,8 +261,8 @@ the container is stored in ``self::$container``::
261261
// (1) boot the Symfony kernel
262262
self::bootKernel();
263263

264-
// (2) use self::$container to access the service container
265-
$container = self::$container;
264+
// (2) use static::getContainer() to access the service container
265+
$container = static::getContainer();
266266

267267
// (3) run some service & test the result
268268
$newsletterGenerator = $container->get(NewsletterGenerator::class);
@@ -272,7 +272,7 @@ the container is stored in ``self::$container``::
272272
}
273273
}
274274

275-
The container in ``self::$container`` is actually a special test container.
275+
The container in ``static::getContainer()`` is actually a special test container.
276276
It gives you access to both the public services and the non-removed
277277
:ref:`private services <container-public>` services.
278278

0 commit comments

Comments
 (0)