-
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.
test: add coverage for
CommandNameNotResolvable
(#81)
Co-authored-by: Alex Longshaw <[email protected]>
- Loading branch information
1 parent
b4174ed
commit c70c451
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
tests/unit/Command/Naming/CommandNameNotResolvableTest.php
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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Unit\Lendable\Message\Command\Naming; | ||
|
||
use Lendable\Message\Command\Command; | ||
use Lendable\Message\Command\Naming\CommandNameNotResolvable; | ||
use Lendable\Message\CorrelationId; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\DisableReturnValueGenerationForTestDoubles; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\TestCase; | ||
use Tests\Fixtures\Lendable\Message\Command\ExampleFooCommand; | ||
|
||
#[CoversClass(CommandNameNotResolvable::class)] | ||
#[DisableReturnValueGenerationForTestDoubles] | ||
final class CommandNameNotResolvableTest extends TestCase | ||
{ | ||
#[Test] | ||
public function it_can_be_constructed_from_a_command(): void | ||
{ | ||
$command = ExampleFooCommand::fresh(CorrelationId::generate()); | ||
$exception = CommandNameNotResolvable::for($command); | ||
|
||
self::assertSame($this->expectedExceptionMessage($command), $exception->getMessage()); | ||
self::assertNull($exception->getPrevious()); | ||
} | ||
|
||
#[Test] | ||
public function it_can_be_constructed_from_a_command_and_triggering_throwable(): void | ||
{ | ||
$command = ExampleFooCommand::fresh(CorrelationId::generate()); | ||
$previous = new \RuntimeException(); | ||
$exception = CommandNameNotResolvable::for($command, $previous); | ||
|
||
self::assertSame($this->expectedExceptionMessage($command), $exception->getMessage()); | ||
self::assertSame($previous, $exception->getPrevious()); | ||
} | ||
|
||
private function expectedExceptionMessage(Command $command): string | ||
{ | ||
return \sprintf('Command message name for %s<%s> could not be resolved.', $command::class, $command->id()->toString()); | ||
} | ||
} |