feat: analyse import + all tests fixed
This commit is contained in:
parent
fbe9619224
commit
3170a7c60e
43
tests/Shared/Adapter/InMemoryEventDispatcher.php
Normal file
43
tests/Shared/Adapter/InMemoryEventDispatcher.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Shared\Adapter;
|
||||
|
||||
use App\Domain\Shared\Domain\Contract\EventDispatcherInterface;
|
||||
|
||||
class InMemoryEventDispatcher implements EventDispatcherInterface
|
||||
{
|
||||
/** @var array<object> */
|
||||
private array $dispatchedEvents = [];
|
||||
|
||||
public function dispatch(object $event): void
|
||||
{
|
||||
$this->dispatchedEvents[] = $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<object>
|
||||
*/
|
||||
public function getDispatchedEvents(): array
|
||||
{
|
||||
return $this->dispatchedEvents;
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
$this->dispatchedEvents = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T of object
|
||||
* @param class-string<T> $eventClass
|
||||
* @return array<T>
|
||||
*/
|
||||
public function getDispatchedEventsOfType(string $eventClass): array
|
||||
{
|
||||
return array_filter(
|
||||
$this->dispatchedEvents,
|
||||
fn(object $event) => $event instanceof $eventClass
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user