Skip to content

Commit

Permalink
Add compatibility with SF 3.12 dispatchers
Browse files Browse the repository at this point in the history
  • Loading branch information
msmakouz committed Jan 17, 2024
1 parent 03808a8 commit 1f3f453
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/Traits/InteractsWithDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trait InteractsWithDispatcher
public function assertDispatcherCanBeServed(string $dispatcher): void
{
$this->assertTrue(
$this->getContainer()->get($dispatcher)->canServe(),
$this->getContainer()->invoke([$dispatcher, 'canServe']),
\sprintf('Dispatcher [%s] can not be served.', $dispatcher)
);
}
Expand All @@ -26,7 +26,7 @@ public function assertDispatcherCanBeServed(string $dispatcher): void
public function assertDispatcherCannotBeServed(string $dispatcher): void
{
$this->assertFalse(
$this->getContainer()->get($dispatcher)->canServe(),
$this->getContainer()->invoke([$dispatcher, 'canServe']),
\sprintf('Dispatcher [%s] can be served.', $dispatcher)
);
}
Expand Down Expand Up @@ -77,8 +77,6 @@ public function assertDispatcherMissed(string $dispatcher): void
*/
public function getRegisteredDispatchers(): array
{
return array_map(static function ($dispatcher): string {
return get_class($dispatcher);
}, $this->getContainer()->get(KernelInterface::class)->getRegisteredDispatchers());
return $this->getContainer()->get(KernelInterface::class)->getRegisteredDispatchers();
}
}
8 changes: 6 additions & 2 deletions src/Traits/TestableKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ public function getContainer(): Container
return $this->container;
}

/** @return DispatcherInterface[] */
/** @return array<class-string<DispatcherInterface>> */
public function getRegisteredDispatchers(): array
{
return $this->dispatchers;
return \array_map(static fn (string|DispatcherInterface $dispatcher): string => \is_object($dispatcher)
? $dispatcher::class
: $dispatcher,
$this->dispatchers
);
}

/** @return array<class-string> */
Expand Down

0 comments on commit 1f3f453

Please sign in to comment.