@@ 890-896 (lines=7) @@ | ||
887 | ->shouldReturn([1 => 1, 3 => 2, 2 => 1]); |
|
888 | } |
|
889 | ||
890 | function it_can_get_first_item() |
|
891 | { |
|
892 | $this->beConstructedWith([1, [2], 3]); |
|
893 | $this->first()->shouldReturn(1); |
|
894 | $this->drop(1)->first()->shouldReturn([2]); |
|
895 | $this->drop(1)->first(true)->toArray()->shouldReturn([2]); |
|
896 | } |
|
897 | ||
898 | function it_will_throw_when_trying_to_get_first_item_of_empty_collection() |
|
899 | { |
|
@@ 904-910 (lines=7) @@ | ||
901 | $this->shouldThrow(ItemNotFound::class)->during('first'); |
|
902 | } |
|
903 | ||
904 | function it_can_get_last_item() |
|
905 | { |
|
906 | $this->beConstructedWith([1, [2], 3]); |
|
907 | $this->last()->shouldReturn(3); |
|
908 | $this->take(2)->last()->shouldReturn([2]); |
|
909 | $this->take(2)->last(true)->toArray()->shouldReturn([2]); |
|
910 | } |
|
911 | ||
912 | function it_will_throw_when_trying_to_get_last_item_of_empty_collection() |
|
913 | { |