| @@ 196-206 (lines=11) @@ | ||
| 193 | $collection->size()->shouldReturn(6); |
|
| 194 | } |
|
| 195 | ||
| 196 | function it_can_map() |
|
| 197 | { |
|
| 198 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 199 | ||
| 200 | $this |
|
| 201 | ->map(function ($item) { |
|
| 202 | return $item + 1; |
|
| 203 | }) |
|
| 204 | ->toArray() |
|
| 205 | ->shouldReturn([2, 4, 4, 3]); |
|
| 206 | } |
|
| 207 | ||
| 208 | function it_can_reduce() |
|
| 209 | { |
|
| @@ 671-680 (lines=10) @@ | ||
| 668 | ->shouldReturn([1, 3, 3, 2, 1, 3, 3, 2]); |
|
| 669 | } |
|
| 670 | ||
| 671 | function it_can_prepend_item() |
|
| 672 | { |
|
| 673 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 674 | ||
| 675 | $this |
|
| 676 | ->prepend(1) |
|
| 677 | ->values() |
|
| 678 | ->toArray() |
|
| 679 | ->shouldReturn([1, 1, 3, 3, 2]); |
|
| 680 | } |
|
| 681 | ||
| 682 | function it_can_prepend_item_with_key() |
|
| 683 | { |
|
| @@ 692-701 (lines=10) @@ | ||
| 689 | ->shouldReturn(['a' => 1, 0 => 1, 1 => 3, 2 => 3, 3 => 2]); |
|
| 690 | } |
|
| 691 | ||
| 692 | function it_can_append_item() |
|
| 693 | { |
|
| 694 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 695 | ||
| 696 | $this |
|
| 697 | ->append(1) |
|
| 698 | ->values() |
|
| 699 | ->toArray() |
|
| 700 | ->shouldReturn([1, 3, 3, 2, 1]); |
|
| 701 | } |
|
| 702 | ||
| 703 | function it_can_append_item_with_key() |
|
| 704 | { |
|
| @@ 802-810 (lines=9) @@ | ||
| 799 | $s2->second()->toArray()->shouldBe([1 => 3, 2 => 3, 3 => 2]); |
|
| 800 | } |
|
| 801 | ||
| 802 | function it_can_replace_items_by_items_from_another_collection() |
|
| 803 | { |
|
| 804 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 805 | ||
| 806 | $this |
|
| 807 | ->replace([3 => 'a']) |
|
| 808 | ->toArray() |
|
| 809 | ->shouldReturn([1, 'a', 'a', 2]); |
|
| 810 | } |
|
| 811 | ||
| 812 | function it_can_get_reduction_steps() |
|
| 813 | { |
|
| @@ 812-825 (lines=14) @@ | ||
| 809 | ->shouldReturn([1, 'a', 'a', 2]); |
|
| 810 | } |
|
| 811 | ||
| 812 | function it_can_get_reduction_steps() |
|
| 813 | { |
|
| 814 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 815 | ||
| 816 | $this |
|
| 817 | ->reductions( |
|
| 818 | function ($tmp, $i) { |
|
| 819 | return $tmp + $i; |
|
| 820 | }, |
|
| 821 | 0 |
|
| 822 | ) |
|
| 823 | ->toArray() |
|
| 824 | ->shouldReturn([0, 1, 4, 7, 9]); |
|
| 825 | } |
|
| 826 | ||
| 827 | function it_can_return_every_nth_item() |
|
| 828 | { |
|