| @@ 140-150 (lines=11) @@ | ||
| 137 | $collection->size()->shouldReturn(6); |
|
| 138 | } |
|
| 139 | ||
| 140 | function it_can_map() |
|
| 141 | { |
|
| 142 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 143 | ||
| 144 | $this |
|
| 145 | ->map(function ($item) { |
|
| 146 | return $item + 1; |
|
| 147 | }) |
|
| 148 | ->toArray() |
|
| 149 | ->shouldReturn([2, 4, 4, 3]); |
|
| 150 | } |
|
| 151 | ||
| 152 | function it_can_reduce() |
|
| 153 | { |
|
| @@ 626-635 (lines=10) @@ | ||
| 623 | ->shouldReturn([1, 3, 3, 2, 1, 3, 3, 2]); |
|
| 624 | } |
|
| 625 | ||
| 626 | function it_can_prepend_item() |
|
| 627 | { |
|
| 628 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 629 | ||
| 630 | $this |
|
| 631 | ->prepend(1) |
|
| 632 | ->values() |
|
| 633 | ->toArray() |
|
| 634 | ->shouldReturn([1, 1, 3, 3, 2]); |
|
| 635 | } |
|
| 636 | ||
| 637 | function it_can_prepend_item_with_key() |
|
| 638 | { |
|
| @@ 647-656 (lines=10) @@ | ||
| 644 | ->shouldReturn(['a' => 1, 0 => 1, 1 => 3, 2 => 3, 3 => 2]); |
|
| 645 | } |
|
| 646 | ||
| 647 | function it_can_append_item() |
|
| 648 | { |
|
| 649 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 650 | ||
| 651 | $this |
|
| 652 | ->append(1) |
|
| 653 | ->values() |
|
| 654 | ->toArray() |
|
| 655 | ->shouldReturn([1, 3, 3, 2, 1]); |
|
| 656 | } |
|
| 657 | ||
| 658 | function it_can_append_item_with_key() |
|
| 659 | { |
|
| @@ 757-765 (lines=9) @@ | ||
| 754 | $s2->second()->toArray()->shouldBe([1 => 3, 2 => 3, 3 => 2]); |
|
| 755 | } |
|
| 756 | ||
| 757 | function it_can_replace_items_by_items_from_another_collection() |
|
| 758 | { |
|
| 759 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 760 | ||
| 761 | $this |
|
| 762 | ->replace([3 => 'a']) |
|
| 763 | ->toArray() |
|
| 764 | ->shouldReturn([1, 'a', 'a', 2]); |
|
| 765 | } |
|
| 766 | ||
| 767 | function it_can_get_reduction_steps() |
|
| 768 | { |
|
| @@ 767-780 (lines=14) @@ | ||
| 764 | ->shouldReturn([1, 'a', 'a', 2]); |
|
| 765 | } |
|
| 766 | ||
| 767 | function it_can_get_reduction_steps() |
|
| 768 | { |
|
| 769 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 770 | ||
| 771 | $this |
|
| 772 | ->reductions( |
|
| 773 | function ($tmp, $i) { |
|
| 774 | return $tmp + $i; |
|
| 775 | }, |
|
| 776 | 0 |
|
| 777 | ) |
|
| 778 | ->toArray() |
|
| 779 | ->shouldReturn([0, 1, 4, 7, 9]); |
|
| 780 | } |
|
| 781 | ||
| 782 | function it_can_return_every_nth_item() |
|
| 783 | { |
|