-
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
00d280c
commit 0a369ac
Showing
9 changed files
with
363 additions
and
13 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
63 changes: 63 additions & 0 deletions
63
tests/Unit/Subscription/Subscriber/ArgumentResolver/AggregateIdArgumentResolverTest.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,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcing\Tests\Unit\Subscription\Subscriber\ArgumentResolver; | ||
|
||
use DateTimeImmutable; | ||
use Patchlevel\EventSourcing\Aggregate\AggregateHeader; | ||
use Patchlevel\EventSourcing\Message\Message; | ||
use Patchlevel\EventSourcing\Metadata\Subscriber\ArgumentMetadata; | ||
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\AggregateIdArgumentResolver; | ||
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileCreated; | ||
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileId; | ||
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileVisited; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** @covers \Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\AggregateIdArgumentResolver */ | ||
final class AggregateIdArgumentResolverTest extends TestCase | ||
{ | ||
public function testSupport(): void | ||
{ | ||
$resolver = new AggregateIdArgumentResolver(); | ||
|
||
self::assertTrue( | ||
$resolver->support( | ||
new ArgumentMetadata('aggregateId', 'string'), | ||
ProfileCreated::class, | ||
), | ||
); | ||
|
||
self::assertTrue( | ||
$resolver->support( | ||
new ArgumentMetadata('aggregateRootId', 'string'), | ||
ProfileCreated::class, | ||
), | ||
); | ||
|
||
self::assertFalse( | ||
$resolver->support( | ||
new ArgumentMetadata('foo', 'string'), | ||
ProfileCreated::class, | ||
), | ||
); | ||
} | ||
|
||
public function testResolve(): void | ||
{ | ||
$event = new ProfileVisited(ProfileId::fromString('1')); | ||
|
||
$resolver = new AggregateIdArgumentResolver(); | ||
$message = (new Message($event))->withHeader( | ||
new AggregateHeader('foo', 'bar', 1, new DateTimeImmutable()), | ||
); | ||
|
||
self::assertSame( | ||
'bar', | ||
$resolver->resolve( | ||
new ArgumentMetadata('foo', 'string'), | ||
$message, | ||
), | ||
); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
tests/Unit/Subscription/Subscriber/ArgumentResolver/EventArgumentResolverTest.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,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcing\Tests\Unit\Subscription\Subscriber\ArgumentResolver; | ||
|
||
use Patchlevel\EventSourcing\Message\Message; | ||
use Patchlevel\EventSourcing\Metadata\Subscriber\ArgumentMetadata; | ||
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\EventArgumentResolver; | ||
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileCreated; | ||
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileId; | ||
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileVisited; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** @covers \Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\EventArgumentResolver */ | ||
final class EventArgumentResolverTest extends TestCase | ||
{ | ||
public function testSupport(): void | ||
{ | ||
$resolver = new EventArgumentResolver(); | ||
|
||
self::assertTrue( | ||
$resolver->support( | ||
new ArgumentMetadata('foo', ProfileCreated::class), | ||
ProfileCreated::class, | ||
), | ||
); | ||
|
||
self::assertFalse( | ||
$resolver->support( | ||
new ArgumentMetadata('foo', ProfileVisited::class), | ||
ProfileCreated::class, | ||
), | ||
); | ||
} | ||
|
||
public function testResolve(): void | ||
{ | ||
$event = new ProfileVisited(ProfileId::fromString('1')); | ||
|
||
$resolver = new EventArgumentResolver(); | ||
$message = new Message($event); | ||
|
||
self::assertSame( | ||
$event, | ||
$resolver->resolve( | ||
new ArgumentMetadata('foo', ProfileVisited::class), | ||
$message, | ||
), | ||
); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/Unit/Subscription/Subscriber/ArgumentResolver/MessageArgumentResolverTest.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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcing\Tests\Unit\Subscription\Subscriber\ArgumentResolver; | ||
|
||
use Patchlevel\EventSourcing\Message\Message; | ||
use Patchlevel\EventSourcing\Metadata\Subscriber\ArgumentMetadata; | ||
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\MessageArgumentResolver; | ||
use PHPUnit\Framework\TestCase; | ||
use stdClass; | ||
|
||
/** @covers \Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\MessageArgumentResolver */ | ||
final class MessageArgumentResolverTest extends TestCase | ||
{ | ||
public function testSupport(): void | ||
{ | ||
$resolver = new MessageArgumentResolver(); | ||
|
||
self::assertTrue( | ||
$resolver->support( | ||
new ArgumentMetadata('foo', Message::class), | ||
'qux', | ||
), | ||
); | ||
|
||
self::assertFalse( | ||
$resolver->support( | ||
new ArgumentMetadata('foo', 'bar'), | ||
'qux', | ||
), | ||
); | ||
} | ||
|
||
public function testResolve(): void | ||
{ | ||
$resolver = new MessageArgumentResolver(); | ||
$message = new Message(new stdClass()); | ||
|
||
self::assertSame( | ||
$message, | ||
$resolver->resolve( | ||
new ArgumentMetadata('foo', Message::class), | ||
$message, | ||
), | ||
); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
tests/Unit/Subscription/Subscriber/ArgumentResolver/RecordedOnArgumentResolverTest.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,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcing\Tests\Unit\Subscription\Subscriber\ArgumentResolver; | ||
|
||
use DateTimeImmutable; | ||
use Patchlevel\EventSourcing\Aggregate\AggregateHeader; | ||
use Patchlevel\EventSourcing\Message\Message; | ||
use Patchlevel\EventSourcing\Metadata\Subscriber\ArgumentMetadata; | ||
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\RecordedOnArgumentResolver; | ||
use PHPUnit\Framework\TestCase; | ||
use stdClass; | ||
|
||
/** @covers \Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\RecordedOnArgumentResolver */ | ||
final class RecordedOnArgumentResolverTest extends TestCase | ||
{ | ||
public function testSupport(): void | ||
{ | ||
$resolver = new RecordedOnArgumentResolver(); | ||
|
||
self::assertTrue( | ||
$resolver->support( | ||
new ArgumentMetadata('foo', DateTimeImmutable::class), | ||
'qux', | ||
), | ||
); | ||
|
||
self::assertFalse( | ||
$resolver->support( | ||
new ArgumentMetadata('foo', 'bar'), | ||
'qux', | ||
), | ||
); | ||
} | ||
|
||
public function testResolve(): void | ||
{ | ||
$date = new DateTimeImmutable(); | ||
|
||
$resolver = new RecordedOnArgumentResolver(); | ||
$message = (new Message(new stdClass()))->withHeader( | ||
new AggregateHeader( | ||
'foo', | ||
'bar', | ||
1, | ||
$date, | ||
), | ||
); | ||
|
||
self::assertSame( | ||
$date, | ||
$resolver->resolve( | ||
new ArgumentMetadata('foo', DateTimeImmutable::class), | ||
$message, | ||
), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.