Skip to content

Commit 003608e

Browse files
committed
Fix mercure context
1 parent 6ad1fbc commit 003608e

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tests/Behat/MercureContext.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@
1212
declare(strict_types=1);
1313

1414
use ApiPlatform\Core\Tests\Fixtures\DummyMercurePublisher;
15+
use Behat\Behat\Context\Context;
1516
use Behat\Gherkin\Node\PyStringNode;
16-
use Behat\Symfony2Extension\Context\KernelAwareContext;
17-
use Symfony\Component\HttpKernel\KernelInterface;
1817
use Symfony\Component\Mercure\Update;
1918

2019
/**
2120
* Context for Mercure.
2221
*
2322
* @author Alan Poulain <[email protected]>
2423
*/
25-
final class MercureContext implements KernelAwareContext
24+
final class MercureContext implements Context
2625
{
27-
private $kernel;
26+
private $publisher;
2827

29-
public function setKernel(KernelInterface $kernel): void
28+
public function __construct(DummyMercurePublisher $publisher)
3029
{
31-
$this->kernel = $kernel;
30+
$this->publisher = $publisher;
3231
}
3332

3433
/**
@@ -38,11 +37,9 @@ public function theFollowingMercureUpdateShouldHaveBeenSent(string $topics, PySt
3837
{
3938
$topics = explode(',', $topics);
4039
$update = json_decode($update->getRaw(), true);
41-
/** @var DummyMercurePublisher $publisher */
42-
$publisher = $this->kernel->getContainer()->get('mercure.hub.default.publisher');
4340

4441
/** @var Update $sentUpdate */
45-
foreach ($publisher->getUpdates() as $sentUpdate) {
42+
foreach ($this->publisher->getUpdates() as $sentUpdate) {
4643
$toMatchTopics = count($topics);
4744
foreach ($sentUpdate->getTopics() as $sentTopic) {
4845
foreach ($topics as $topic) {

0 commit comments

Comments
 (0)