| @@ 197-207 (lines=11) @@ | ||
| 194 | $collection->size()->shouldReturn(6); |
|
| 195 | } |
|
| 196 | ||
| 197 | function it_can_map() |
|
| 198 | { |
|
| 199 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 200 | ||
| 201 | $this |
|
| 202 | ->map(function ($item) { |
|
| 203 | return $item + 1; |
|
| 204 | }) |
|
| 205 | ->toArray() |
|
| 206 | ->shouldReturn([2, 4, 4, 3]); |
|
| 207 | } |
|
| 208 | ||
| 209 | function it_can_reduce() |
|
| 210 | { |
|
| @@ 528-542 (lines=15) @@ | ||
| 525 | ->shouldReturn(false); |
|
| 526 | } |
|
| 527 | ||
| 528 | function it_can_reverse() |
|
| 529 | { |
|
| 530 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 531 | ||
| 532 | $this |
|
| 533 | ->reverse() |
|
| 534 | ->toArray() |
|
| 535 | ->shouldReturn([ |
|
| 536 | 3 => 2, |
|
| 537 | 2 => 3, |
|
| 538 | 1 => 3, |
|
| 539 | 0 => 1, |
|
| 540 | ]) |
|
| 541 | ; |
|
| 542 | } |
|
| 543 | ||
| 544 | function it_can_reduce_from_right() |
|
| 545 | { |
|
| @@ 679-688 (lines=10) @@ | ||
| 676 | ->shouldReturn([1, 3, 3, 2, 1, 3, 3, 2]); |
|
| 677 | } |
|
| 678 | ||
| 679 | function it_can_prepend_item() |
|
| 680 | { |
|
| 681 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 682 | ||
| 683 | $this |
|
| 684 | ->prepend(1) |
|
| 685 | ->values() |
|
| 686 | ->toArray() |
|
| 687 | ->shouldReturn([1, 1, 3, 3, 2]); |
|
| 688 | } |
|
| 689 | ||
| 690 | function it_can_prepend_item_with_key() |
|
| 691 | { |
|
| @@ 700-709 (lines=10) @@ | ||
| 697 | ->shouldReturn(['a' => 1, 0 => 1, 1 => 3, 2 => 3, 3 => 2]); |
|
| 698 | } |
|
| 699 | ||
| 700 | function it_can_append_item() |
|
| 701 | { |
|
| 702 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 703 | ||
| 704 | $this |
|
| 705 | ->append(1) |
|
| 706 | ->values() |
|
| 707 | ->toArray() |
|
| 708 | ->shouldReturn([1, 3, 3, 2, 1]); |
|
| 709 | } |
|
| 710 | ||
| 711 | function it_can_append_item_with_key() |
|
| 712 | { |
|
| @@ 810-818 (lines=9) @@ | ||
| 807 | $s2->second()->toArray()->shouldBe([1 => 3, 2 => 3, 3 => 2]); |
|
| 808 | } |
|
| 809 | ||
| 810 | function it_can_replace_items_by_items_from_another_collection() |
|
| 811 | { |
|
| 812 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 813 | ||
| 814 | $this |
|
| 815 | ->replace([3 => 'a']) |
|
| 816 | ->toArray() |
|
| 817 | ->shouldReturn([1, 'a', 'a', 2]); |
|
| 818 | } |
|
| 819 | ||
| 820 | function it_can_get_reduction_steps() |
|
| 821 | { |
|
| @@ 820-833 (lines=14) @@ | ||
| 817 | ->shouldReturn([1, 'a', 'a', 2]); |
|
| 818 | } |
|
| 819 | ||
| 820 | function it_can_get_reduction_steps() |
|
| 821 | { |
|
| 822 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 823 | ||
| 824 | $this |
|
| 825 | ->reductions( |
|
| 826 | function ($tmp, $i) { |
|
| 827 | return $tmp + $i; |
|
| 828 | }, |
|
| 829 | 0 |
|
| 830 | ) |
|
| 831 | ->toArray() |
|
| 832 | ->shouldReturn([0, 1, 4, 7, 9]); |
|
| 833 | } |
|
| 834 | ||
| 835 | function it_can_return_every_nth_item() |
|
| 836 | { |
|