-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
917 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2025 Cloud Creativity Limited | ||
* | ||
* Use of this source code is governed by an MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CloudCreativity\Modules\Testing; | ||
|
||
use CloudCreativity\Modules\Contracts\Domain\Events\DomainEvent; | ||
use CloudCreativity\Modules\Contracts\Domain\Events\DomainEventDispatcher; | ||
use LogicException; | ||
|
||
class FakeDomainEventDispatcher implements DomainEventDispatcher | ||
{ | ||
/** | ||
* @var array<DomainEvent> | ||
*/ | ||
public array $events = []; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function dispatch(DomainEvent $event): void | ||
{ | ||
$this->events[] = $event; | ||
} | ||
|
||
/** | ||
* Expect a single event to be dispatched and return it. | ||
* | ||
* @return DomainEvent | ||
*/ | ||
public function sole(): DomainEvent | ||
{ | ||
if (count($this->events) === 1) { | ||
return $this->events[0]; | ||
} | ||
|
||
throw new LogicException(sprintf( | ||
'Expected one event to be dispatched but there are %d events.', | ||
count($this->events), | ||
)); | ||
} | ||
} |
Oops, something went wrong.