diff --git a/spec/loophp/collection/CollectionSpec.php b/spec/loophp/collection/CollectionSpec.php index 5f2765fc3..1e0f1ec97 100644 --- a/spec/loophp/collection/CollectionSpec.php +++ b/spec/loophp/collection/CollectionSpec.php @@ -3034,6 +3034,34 @@ public function it_can_zip(): void ->shouldIterateAs([[1, 'A'], [2, 'B'], [3, 'C'], [4, 'D'], [5, 'E']]); } + /** + * @see https://github.com/loophp/collection/issues/57 + */ + public function it_fix_bug_57() + { + $input = array_combine(range(1, 26), range('a', 'z')); + + $collection = $this::fromIterable($input); + + $collection + ->key() + ->shouldReturn(1); + + $collection + ->current() + ->shouldReturn('a'); + + $last = $collection->last(); + + $last + ->key() + ->shouldReturn(26); + + $last + ->current() + ->shouldReturn('z'); + } + public function it_is_initializable(): void { $this->shouldHaveType(Collection::class);