From 29126297f8c37e21236c1426b35704c80ca0e7b2 Mon Sep 17 00:00:00 2001 From: Andrea Marco Sartori Date: Mon, 28 Oct 2024 17:56:09 -0300 Subject: [PATCH] Add has() method --- tests/CasesCollectionTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/CasesCollectionTest.php b/tests/CasesCollectionTest.php index 397c257..7dcaeb6 100644 --- a/tests/CasesCollectionTest.php +++ b/tests/CasesCollectionTest.php @@ -20,6 +20,26 @@ ->all() ->toBe([PureEnum::one, PureEnum::two, PureEnum::three]); +it('determines whether a pure collection contains an item', function() { + $collection = new CasesCollection(PureEnum::cases()); + + expect($collection->has(PureEnum::one))->toBeTrue(); + expect($collection->has('one'))->toBeTrue(); + expect($collection->has(BackedEnum::one))->toBeFalse(); + expect($collection->has('four'))->toBeFalse(); + expect($collection->has(1))->toBeFalse(); +}); + +it('determines whether a backed collection contains an item', function() { + $collection = new CasesCollection(BackedEnum::cases()); + + expect($collection->has(BackedEnum::one))->toBeTrue(); + expect($collection->has(1))->toBeTrue(); + expect($collection->has(PureEnum::one))->toBeFalse(); + expect($collection->has(4))->toBeFalse(); + expect($collection->has('one'))->toBeFalse(); +}); + it('retrieves the count of all the cases') ->expect(new CasesCollection(PureEnum::cases())) ->count()