diff --git a/tests/Unit/Subscription/Engine/SubscriptionCollectionTest.php b/tests/Unit/Subscription/Engine/SubscriptionCollectionTest.php new file mode 100644 index 00000000..5c7d2bdf --- /dev/null +++ b/tests/Unit/Subscription/Engine/SubscriptionCollectionTest.php @@ -0,0 +1,48 @@ +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()); + } +} diff --git a/tests/Unit/Subscription/Engine/SubscriptionManagerTest.php b/tests/Unit/Subscription/Engine/SubscriptionManagerTest.php index d779ded8..0bc9cd50 100644 --- a/tests/Unit/Subscription/Engine/SubscriptionManagerTest.php +++ b/tests/Unit/Subscription/Engine/SubscriptionManagerTest.php @@ -109,7 +109,7 @@ public function testFind(): void $manager = new SubscriptionManager($store->reveal()); $result = $manager->find($criteria); - self::assertSame([$subscription], iterator_to_array($result)); + self::assertSame([$subscription], $result); } public function testFindForUpdateWithoutLock(): void