-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
508eedd
commit 0aa0335
Showing
2 changed files
with
61 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileId; | ||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\PhpUnit\ProphecyTrait; | ||
use RuntimeException; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Output\BufferedOutput; | ||
|
||
|
@@ -23,7 +24,7 @@ final class OutputStyleTest extends TestCase | |
{ | ||
use ProphecyTrait; | ||
|
||
public function testWrite(): void | ||
public function testMessage(): void | ||
{ | ||
$input = new ArrayInput([]); | ||
$output = new BufferedOutput(); | ||
|
@@ -52,8 +53,38 @@ public function testWrite(): void | |
$content = $output->fetch(); | ||
|
||
self::assertStringContainsString('profile.created', $content); | ||
self::assertStringContainsString('Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileCreated', $content); | ||
self::assertStringContainsString('Patchlevel\EventSourcing\Tests\Unit\Fixture\Profile', $content); | ||
self::assertStringContainsString('profile', $content); | ||
self::assertStringContainsString('{"id":"1","email":"[email protected]"}', $content); | ||
} | ||
|
||
public function testMessageWithError(): void | ||
{ | ||
$input = new ArrayInput([]); | ||
$output = new BufferedOutput(); | ||
|
||
$event = new ProfileCreated( | ||
ProfileId::fromString('1'), | ||
Email::fromString('[email protected]'), | ||
); | ||
|
||
$serializer = $this->prophesize(EventSerializer::class); | ||
$serializer | ||
->serialize($event, [Encoder::OPTION_PRETTY_PRINT => true]) | ||
->willThrow(new RuntimeException('Unknown Error')); | ||
|
||
$message = Message::create($event) | ||
->withAggregateName('profile') | ||
->withAggregateId('1') | ||
->withPlayhead(1) | ||
->withRecordedOn(new DateTimeImmutable()); | ||
|
||
$console = new OutputStyle($input, $output); | ||
|
||
$console->message($serializer->reveal(), $message); | ||
|
||
$content = $output->fetch(); | ||
|
||
self::assertStringContainsString('Unknown Error', $content); | ||
self::assertStringContainsString(ProfileCreated::class, $content); | ||
} | ||
} |