|
@@ 288-294 (lines=7) @@
|
| 285 |
|
$this->getOrDefault(5, 'not found')->shouldReturn('not found'); |
| 286 |
|
} |
| 287 |
|
|
| 288 |
|
function it_can_get_nth_item() |
| 289 |
|
{ |
| 290 |
|
$this->beConstructedWith([1, [2], 3]); |
| 291 |
|
$this->getNth(0)->shouldReturn(1); |
| 292 |
|
$this->getNth(1, true)->first()->shouldReturn(2); |
| 293 |
|
$this->getNth(1)->shouldReturn([2]); |
| 294 |
|
} |
| 295 |
|
|
| 296 |
|
function it_can_find() |
| 297 |
|
{ |
|
@@ 837-843 (lines=7) @@
|
| 834 |
|
->shouldReturn([1 => 1, 3 => 2, 2 => 1]); |
| 835 |
|
} |
| 836 |
|
|
| 837 |
|
function it_can_get_first_item() |
| 838 |
|
{ |
| 839 |
|
$this->beConstructedWith([1, [2], 3]); |
| 840 |
|
$this->first()->shouldReturn(1); |
| 841 |
|
$this->drop(1)->first()->shouldReturn([2]); |
| 842 |
|
$this->drop(1)->first(true)->toArray()->shouldReturn([2]); |
| 843 |
|
} |
| 844 |
|
|
| 845 |
|
function it_will_throw_when_trying_to_get_first_item_of_empty_collection() |
| 846 |
|
{ |
|
@@ 851-857 (lines=7) @@
|
| 848 |
|
$this->shouldThrow(ItemNotFound::class)->during('first'); |
| 849 |
|
} |
| 850 |
|
|
| 851 |
|
function it_can_get_last_item() |
| 852 |
|
{ |
| 853 |
|
$this->beConstructedWith([1, [2], 3]); |
| 854 |
|
$this->last()->shouldReturn(3); |
| 855 |
|
$this->take(2)->last()->shouldReturn([2]); |
| 856 |
|
$this->take(2)->last(true)->toArray()->shouldReturn([2]); |
| 857 |
|
} |
| 858 |
|
|
| 859 |
|
function it_will_throw_when_trying_to_get_last_item_of_empty_collection() |
| 860 |
|
{ |