| @@ 132-142 (lines=11) @@ | ||
| 129 | $collection->size()->shouldReturn(6); |
|
| 130 | } |
|
| 131 | ||
| 132 | function it_can_map() |
|
| 133 | { |
|
| 134 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 135 | ||
| 136 | $this |
|
| 137 | ->map(function ($item) { |
|
| 138 | return $item + 1; |
|
| 139 | }) |
|
| 140 | ->toArray() |
|
| 141 | ->shouldReturn([2, 4, 4, 3]); |
|
| 142 | } |
|
| 143 | ||
| 144 | function it_can_reduce() |
|
| 145 | { |
|
| @@ 618-627 (lines=10) @@ | ||
| 615 | ->shouldReturn([1, 3, 3, 2, 1, 3, 3, 2]); |
|
| 616 | } |
|
| 617 | ||
| 618 | function it_can_prepend_item() |
|
| 619 | { |
|
| 620 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 621 | ||
| 622 | $this |
|
| 623 | ->prepend(1) |
|
| 624 | ->values() |
|
| 625 | ->toArray() |
|
| 626 | ->shouldReturn([1, 1, 3, 3, 2]); |
|
| 627 | } |
|
| 628 | ||
| 629 | function it_can_prepend_item_with_key() |
|
| 630 | { |
|
| @@ 639-648 (lines=10) @@ | ||
| 636 | ->shouldReturn(['a' => 1, 0 => 1, 1 => 3, 2 => 3, 3 => 2]); |
|
| 637 | } |
|
| 638 | ||
| 639 | function it_can_append_item() |
|
| 640 | { |
|
| 641 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 642 | ||
| 643 | $this |
|
| 644 | ->append(1) |
|
| 645 | ->values() |
|
| 646 | ->toArray() |
|
| 647 | ->shouldReturn([1, 3, 3, 2, 1]); |
|
| 648 | } |
|
| 649 | ||
| 650 | function it_can_append_item_with_key() |
|
| 651 | { |
|
| @@ 749-757 (lines=9) @@ | ||
| 746 | $s2->second()->toArray()->shouldBe([1 => 3, 2 => 3, 3 => 2]); |
|
| 747 | } |
|
| 748 | ||
| 749 | function it_can_replace_items_by_items_from_another_collection() |
|
| 750 | { |
|
| 751 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 752 | ||
| 753 | $this |
|
| 754 | ->replace([3 => 'a']) |
|
| 755 | ->toArray() |
|
| 756 | ->shouldReturn([1, 'a', 'a', 2]); |
|
| 757 | } |
|
| 758 | ||
| 759 | function it_can_get_reduction_steps() |
|
| 760 | { |
|
| @@ 759-772 (lines=14) @@ | ||
| 756 | ->shouldReturn([1, 'a', 'a', 2]); |
|
| 757 | } |
|
| 758 | ||
| 759 | function it_can_get_reduction_steps() |
|
| 760 | { |
|
| 761 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
| 762 | ||
| 763 | $this |
|
| 764 | ->reductions( |
|
| 765 | function ($tmp, $i) { |
|
| 766 | return $tmp + $i; |
|
| 767 | }, |
|
| 768 | 0 |
|
| 769 | ) |
|
| 770 | ->toArray() |
|
| 771 | ->shouldReturn([0, 1, 4, 7, 9]); |
|
| 772 | } |
|
| 773 | ||
| 774 | function it_can_return_every_nth_item() |
|
| 775 | { |
|