1313
1414namespace ApiPlatform \Tests \Behat ;
1515
16+ use ApiPlatform \Tests \Fixtures \TestBundle \Mercure \TestHub ;
1617use Behat \Behat \Context \Context ;
1718use Behat \Gherkin \Node \PyStringNode ;
1819use Behat \Gherkin \Node \TableNode ;
@@ -37,7 +38,7 @@ public function __construct(private readonly ContainerInterface $driverContainer
3738 */
3839 public function mercureUpdatesShouldHaveBeenSent (int $ number ): void
3940 {
40- $ updateHandler = $ this ->driverContainer -> get ( ' mercure.hub.default.message_handler ' );
41+ $ updateHandler = $ this ->getMercureTestHub ( );
4142 $ total = \count ($ updateHandler ->getUpdates ());
4243
4344 if (0 === $ total ) {
@@ -70,7 +71,7 @@ public function firstMercureUpdateShouldHaveData(PyStringNode $data): void
7071 */
7172 public function mercureUpdateShouldHaveTopics (int $ index , TableNode $ table ): void
7273 {
73- $ updateHandler = $ this ->driverContainer -> get ( ' mercure.hub.default.message_handler ' );
74+ $ updateHandler = $ this ->getMercureTestHub ( );
7475 $ updates = $ updateHandler ->getUpdates ();
7576
7677 if (0 === \count ($ updates )) {
@@ -90,7 +91,7 @@ public function mercureUpdateShouldHaveTopics(int $index, TableNode $table): voi
9091 */
9192 public function mercureUpdateShouldHaveData (int $ index , PyStringNode $ data ): void
9293 {
93- $ updateHandler = $ this ->driverContainer -> get ( ' mercure.hub.default.message_handler ' );
94+ $ updateHandler = $ this ->getMercureTestHub ( );
9495 $ updates = $ updateHandler ->getUpdates ();
9596
9697 if (0 === \count ($ updates )) {
@@ -113,8 +114,7 @@ public function theFollowingMercureUpdateShouldHaveBeenSent(string $topics, PySt
113114 $ topics = explode (', ' , $ topics );
114115 $ update = json_decode ($ update ->getRaw (), true , 512 , \JSON_THROW_ON_ERROR );
115116
116- $ updateHandler = $ this ->driverContainer ->get ('mercure.hub.default.message_handler ' );
117-
117+ $ updateHandler = $ this ->getMercureTestHub ();
118118 foreach ($ updateHandler ->getUpdates () as $ sentUpdate ) {
119119 $ toMatchTopics = \count ($ topics );
120120 foreach ($ sentUpdate ->getTopics () as $ sentTopic ) {
@@ -136,4 +136,9 @@ public function theFollowingMercureUpdateShouldHaveBeenSent(string $topics, PySt
136136
137137 throw new \RuntimeException ('Mercure update has not been sent. ' );
138138 }
139+
140+ private function getMercureTestHub (): TestHub
141+ {
142+ return $ this ->driverContainer ->get ('mercure.hub.default.test_hub ' );
143+ }
139144}
0 commit comments