-
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
87e3ce3
commit 1d520f0
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
tests/Unit/Subscription/Engine/SubscriptionCollectionTest.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\Engine; | ||
|
||
use Patchlevel\EventSourcing\Subscription\Engine\SubscriptionCollection; | ||
use Patchlevel\EventSourcing\Subscription\Subscription; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
use function iterator_to_array; | ||
|
||
final class SubscriptionCollectionTest extends TestCase | ||
{ | ||
public function testEmpty(): void | ||
{ | ||
$collection = new SubscriptionCollection([]); | ||
|
||
self::assertCount(0, $collection); | ||
self::assertEquals([], iterator_to_array($collection)); | ||
self::assertEquals(0, $collection->lowestPosition()); | ||
} | ||
|
||
public function testSomeSubscription(): void | ||
{ | ||
$subscription1 = new Subscription('foo', position: 5); | ||
$subscription2 = new Subscription('bar', position: 10); | ||
|
||
$collection = new SubscriptionCollection([$subscription1, $subscription2]); | ||
|
||
self::assertCount(2, $collection); | ||
self::assertEquals([$subscription1, $subscription2], iterator_to_array($collection)); | ||
self::assertEquals(5, $collection->lowestPosition()); | ||
} | ||
|
||
public function testRemove(): void | ||
{ | ||
$subscription1 = new Subscription('foo', position: 5); | ||
$subscription2 = new Subscription('bar', position: 10); | ||
|
||
$collection = new SubscriptionCollection([$subscription1, $subscription2]); | ||
$collection->remove($subscription1); | ||
|
||
self::assertCount(1, $collection); | ||
self::assertEquals([$subscription2], iterator_to_array($collection)); | ||
self::assertEquals(10, $collection->lowestPosition()); | ||
} | ||
} |
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