GemberPHP /
message-bus-symfony
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Gember\MessageBusSymfony\Test; |
||
| 6 | |||
| 7 | use Gember\DependencyContracts\Util\Messaging\MessageBus\HandlingMessageFailedException; |
||
| 8 | use Gember\MessageBusSymfony\SymfonyCommandBus; |
||
| 9 | use Gember\MessageBusSymfony\Test\TestDoubles\TestCommand; |
||
| 10 | use Gember\MessageBusSymfony\Test\TestDoubles\TestCommandThrowingException; |
||
| 11 | use Gember\MessageBusSymfony\Test\TestDoubles\TestSymfonyCommandBus; |
||
| 12 | use PHPUnit\Framework\Attributes\Test; |
||
| 13 | use PHPUnit\Framework\TestCase; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @internal |
||
| 17 | */ |
||
| 18 | final class SymfonyCommandBusTest extends TestCase |
||
| 19 | { |
||
| 20 | private SymfonyCommandBus $commandBus; |
||
| 21 | private TestSymfonyCommandBus $symfonyCommandBus; |
||
| 22 | |||
| 23 | protected function setUp(): void |
||
| 24 | { |
||
| 25 | parent::setUp(); |
||
| 26 | |||
| 27 | $this->commandBus = new SymfonyCommandBus( |
||
| 28 | $this->symfonyCommandBus = new TestSymfonyCommandBus(), |
||
| 29 | ); |
||
| 30 | } |
||
| 31 | |||
| 32 | #[Test] |
||
| 33 | public function itShouldHandleCommand(): void |
||
| 34 | { |
||
| 35 | $this->commandBus->handle(new TestCommand()); |
||
| 36 | |||
| 37 | self::assertTrue($this->symfonyCommandBus->isCalled); |
||
| 38 | } |
||
| 39 | |||
| 40 | #[Test] |
||
| 41 | public function itShouldThrowExceptionWhenHandlingCommandFailed(): void |
||
| 42 | { |
||
| 43 | self::expectException(HandlingMessageFailedException::class); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 44 | |||
| 45 | $this->commandBus->handle(new TestCommandThrowingException()); |
||
| 46 | } |
||
| 47 | } |
||
| 48 |