@@ 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 | { |
|
@@ 625-634 (lines=10) @@ | ||
622 | ->shouldReturn([1, 3, 3, 2, 1, 3, 3, 2]); |
|
623 | } |
|
624 | ||
625 | function it_can_prepend_item() |
|
626 | { |
|
627 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
628 | ||
629 | $this |
|
630 | ->prepend(1) |
|
631 | ->values() |
|
632 | ->toArray() |
|
633 | ->shouldReturn([1, 1, 3, 3, 2]); |
|
634 | } |
|
635 | ||
636 | function it_can_prepend_item_with_key() |
|
637 | { |
|
@@ 646-655 (lines=10) @@ | ||
643 | ->shouldReturn(['a' => 1, 0 => 1, 1 => 3, 2 => 3, 3 => 2]); |
|
644 | } |
|
645 | ||
646 | function it_can_append_item() |
|
647 | { |
|
648 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
649 | ||
650 | $this |
|
651 | ->append(1) |
|
652 | ->values() |
|
653 | ->toArray() |
|
654 | ->shouldReturn([1, 3, 3, 2, 1]); |
|
655 | } |
|
656 | ||
657 | function it_can_append_item_with_key() |
|
658 | { |
|
@@ 756-764 (lines=9) @@ | ||
753 | $s2->second()->toArray()->shouldBe([1 => 3, 2 => 3, 3 => 2]); |
|
754 | } |
|
755 | ||
756 | function it_can_replace_items_by_items_from_another_collection() |
|
757 | { |
|
758 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
759 | ||
760 | $this |
|
761 | ->replace([3 => 'a']) |
|
762 | ->toArray() |
|
763 | ->shouldReturn([1, 'a', 'a', 2]); |
|
764 | } |
|
765 | ||
766 | function it_can_get_reduction_steps() |
|
767 | { |
|
@@ 766-779 (lines=14) @@ | ||
763 | ->shouldReturn([1, 'a', 'a', 2]); |
|
764 | } |
|
765 | ||
766 | function it_can_get_reduction_steps() |
|
767 | { |
|
768 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
769 | ||
770 | $this |
|
771 | ->reductions( |
|
772 | function ($tmp, $i) { |
|
773 | return $tmp + $i; |
|
774 | }, |
|
775 | 0 |
|
776 | ) |
|
777 | ->toArray() |
|
778 | ->shouldReturn([0, 1, 4, 7, 9]); |
|
779 | } |
|
780 | ||
781 | function it_can_return_every_nth_item() |
|
782 | { |