From 0f203f022e9337581a5a8b55a0a677e8865a1f66 Mon Sep 17 00:00:00 2001 From: David Badura Date: Fri, 20 Dec 2024 16:18:21 +0100 Subject: [PATCH] add clear method in in memory store --- src/Subscription/Store/InMemorySubscriptionStore.php | 5 +++++ .../Store/InMemorySubscriptionStoreTest.php | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/Subscription/Store/InMemorySubscriptionStore.php b/src/Subscription/Store/InMemorySubscriptionStore.php index ebbf8800d..cad12eedd 100644 --- a/src/Subscription/Store/InMemorySubscriptionStore.php +++ b/src/Subscription/Store/InMemorySubscriptionStore.php @@ -92,4 +92,9 @@ public function remove(Subscription $subscription): void { unset($this->subscriptions[$subscription->id()]); } + + public function clear(): void + { + $this->subscriptions = []; + } } diff --git a/tests/Unit/Subscription/Store/InMemorySubscriptionStoreTest.php b/tests/Unit/Subscription/Store/InMemorySubscriptionStoreTest.php index d9506d6a3..22fb8e2b9 100644 --- a/tests/Unit/Subscription/Store/InMemorySubscriptionStoreTest.php +++ b/tests/Unit/Subscription/Store/InMemorySubscriptionStoreTest.php @@ -151,4 +151,15 @@ public function testFindByAll(): void self::assertEquals([$subscription1], $store->find($criteria)); } + + public function testClear(): void + { + $subscription1 = new Subscription('1', group: 'group1', status: Status::New); + $subscription2 = new Subscription('2', group: 'group2', status: Status::Booting); + + $store = new InMemorySubscriptionStore([$subscription1, $subscription2]); + $store->clear(); + + self::assertSame([], $store->find()); + } }