Skip to content

Commit e2fd9a1

Browse files
committed
fix: mercure
1 parent a582629 commit e2fd9a1

5 files changed

Lines changed: 34 additions & 4 deletions

File tree

tests/Behat/CommandContext.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Behat\Gherkin\Node\TableNode;
1919
use GraphQL\Error\Error;
2020
use PHPUnit\Framework\Assert;
21+
use Psr\Container\ContainerInterface;
2122
use Symfony\Bundle\FrameworkBundle\Console\Application;
2223
use Symfony\Component\Console\Command\Command;
2324
use Symfony\Component\Console\Tester\CommandTester;
@@ -34,7 +35,9 @@ final class CommandContext implements Context
3435

3536
private ?CommandTester $commandTester = null;
3637

37-
public function __construct(private KernelInterface $kernel)
38+
private ?KernelInterface $kernel = null;
39+
40+
public function __construct(private readonly ContainerInterface $driverContainer)
3841
{
3942
}
4043

@@ -92,6 +95,10 @@ public function getApplication(): Application
9295
return $this->application;
9396
}
9497

98+
if (null === $this->kernel) {
99+
$this->kernel = $this->driverContainer->get('kernel');
100+
}
101+
95102
$this->application = new Application($this->kernel);
96103

97104
return $this->application;

tests/Behat/MercureContext.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ public function mercureUpdateShouldHaveData(int $index, PyStringNode $data): voi
103103
}
104104
/** @var Update $update */
105105
$update = $updates[$index - 1];
106-
Assert::assertJsonStringEqualsJsonString($data->getRaw(), $update->getData());
106+
107+
$expectedData = json_decode($data->getRaw(), true, 512, \JSON_THROW_ON_ERROR);
108+
$actualData = json_decode($update->getData(), true, 512, \JSON_THROW_ON_ERROR);
109+
Assert::assertEquals($expectedData, $actualData);
107110
}
108111

109112
/**
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
autoconfigure: true
5+
6+
ApiPlatform\Tests\Behat\CommandContext:
7+
$driverContainer: '@behat.driver.service_container'
8+
ApiPlatform\Tests\Behat\DoctrineContext:
9+
$doctrine: '@doctrine'
10+
ApiPlatform\Tests\Behat\HttpCacheContext: ~
11+
ApiPlatform\Tests\Behat\HydraContext: ~
12+
ApiPlatform\Tests\Behat\JsonApiContext:
13+
$doctrine: '@doctrine'
14+
$jsonApiSchemaFile: '%kernel.project_dir%/../JsonSchema/jsonapi.json'
15+
ApiPlatform\Tests\Behat\JsonHalContext:
16+
$schemaFile: '%kernel.project_dir%/../JsonHal/jsonhal.json'
17+
ApiPlatform\Tests\Behat\MercureContext:
18+
$driverContainer: '@behat.driver.service_container'

tests/Fixtures/app/config/config_behat_mongodb.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ services:
33
autowire: true
44
autoconfigure: true
55

6-
ApiPlatform\Tests\Behat\CommandContext: ~
6+
ApiPlatform\Tests\Behat\CommandContext:
7+
$driverContainer: '@behat.driver.service_container'
78
ApiPlatform\Tests\Behat\DoctrineContext:
89
$doctrine: '@doctrine_mongodb'
910
ApiPlatform\Tests\Behat\HttpCacheContext: ~

tests/Fixtures/app/config/config_behat_orm.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ services:
44
autowire: true
55
autoconfigure: true
66

7-
ApiPlatform\Tests\Behat\CommandContext: ~
7+
ApiPlatform\Tests\Behat\CommandContext:
8+
$driverContainer: '@behat.driver.service_container'
89
ApiPlatform\Tests\Behat\DoctrineContext:
910
$doctrine: '@doctrine'
1011
ApiPlatform\Tests\Behat\HttpCacheContext: ~

0 commit comments

Comments
 (0)