13
13
14
14
namespace ApiPlatform \Tests \Behat ;
15
15
16
+ use ApiPlatform \Tests \Fixtures \TestBundle \Mercure \TestHub ;
16
17
use Behat \Behat \Context \Context ;
17
18
use Behat \Gherkin \Node \PyStringNode ;
18
19
use Behat \Gherkin \Node \TableNode ;
@@ -37,7 +38,7 @@ public function __construct(private readonly ContainerInterface $driverContainer
37
38
*/
38
39
public function mercureUpdatesShouldHaveBeenSent (int $ number ): void
39
40
{
40
- $ updateHandler = $ this ->driverContainer -> get ( ' mercure.hub.default.message_handler ' );
41
+ $ updateHandler = $ this ->getMercureTestHub ( );
41
42
$ total = \count ($ updateHandler ->getUpdates ());
42
43
43
44
if (0 === $ total ) {
@@ -70,7 +71,7 @@ public function firstMercureUpdateShouldHaveData(PyStringNode $data): void
70
71
*/
71
72
public function mercureUpdateShouldHaveTopics (int $ index , TableNode $ table ): void
72
73
{
73
- $ updateHandler = $ this ->driverContainer -> get ( ' mercure.hub.default.message_handler ' );
74
+ $ updateHandler = $ this ->getMercureTestHub ( );
74
75
$ updates = $ updateHandler ->getUpdates ();
75
76
76
77
if (0 === \count ($ updates )) {
@@ -90,7 +91,7 @@ public function mercureUpdateShouldHaveTopics(int $index, TableNode $table): voi
90
91
*/
91
92
public function mercureUpdateShouldHaveData (int $ index , PyStringNode $ data ): void
92
93
{
93
- $ updateHandler = $ this ->driverContainer -> get ( ' mercure.hub.default.message_handler ' );
94
+ $ updateHandler = $ this ->getMercureTestHub ( );
94
95
$ updates = $ updateHandler ->getUpdates ();
95
96
96
97
if (0 === \count ($ updates )) {
@@ -113,8 +114,7 @@ public function theFollowingMercureUpdateShouldHaveBeenSent(string $topics, PySt
113
114
$ topics = explode (', ' , $ topics );
114
115
$ update = json_decode ($ update ->getRaw (), true , 512 , \JSON_THROW_ON_ERROR );
115
116
116
- $ updateHandler = $ this ->driverContainer ->get ('mercure.hub.default.message_handler ' );
117
-
117
+ $ updateHandler = $ this ->getMercureTestHub ();
118
118
foreach ($ updateHandler ->getUpdates () as $ sentUpdate ) {
119
119
$ toMatchTopics = \count ($ topics );
120
120
foreach ($ sentUpdate ->getTopics () as $ sentTopic ) {
@@ -136,4 +136,9 @@ public function theFollowingMercureUpdateShouldHaveBeenSent(string $topics, PySt
136
136
137
137
throw new \RuntimeException ('Mercure update has not been sent. ' );
138
138
}
139
+
140
+ private function getMercureTestHub (): TestHub
141
+ {
142
+ return $ this ->driverContainer ->get ('mercure.hub.default.test_hub ' );
143
+ }
139
144
}
0 commit comments