Skip to content

Commit

Permalink
add clear method in in memory store
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed Dec 20, 2024
1 parent 669b62f commit 0f203f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Subscription/Store/InMemorySubscriptionStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,9 @@ public function remove(Subscription $subscription): void
{
unset($this->subscriptions[$subscription->id()]);
}

public function clear(): void
{
$this->subscriptions = [];
}
}
11 changes: 11 additions & 0 deletions tests/Unit/Subscription/Store/InMemorySubscriptionStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 0f203f0

Please sign in to comment.