@@ 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 | { |
|
@@ 604-613 (lines=10) @@ | ||
601 | ->shouldReturn([1, 3, 3, 2, 1, 3, 3, 2]); |
|
602 | } |
|
603 | ||
604 | function it_can_prepend_item() |
|
605 | { |
|
606 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
607 | ||
608 | $this |
|
609 | ->prepend(1) |
|
610 | ->values() |
|
611 | ->toArray() |
|
612 | ->shouldReturn([1, 1, 3, 3, 2]); |
|
613 | } |
|
614 | ||
615 | function it_can_prepend_item_with_key() |
|
616 | { |
|
@@ 625-634 (lines=10) @@ | ||
622 | ->shouldReturn(['a' => 1, 0 => 1, 1 => 3, 2 => 3, 3 => 2]); |
|
623 | } |
|
624 | ||
625 | function it_can_append_item() |
|
626 | { |
|
627 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
628 | ||
629 | $this |
|
630 | ->append(1) |
|
631 | ->values() |
|
632 | ->toArray() |
|
633 | ->shouldReturn([1, 3, 3, 2, 1]); |
|
634 | } |
|
635 | ||
636 | function it_can_append_item_with_key() |
|
637 | { |
|
@@ 735-743 (lines=9) @@ | ||
732 | $s2->second()->toArray()->shouldBe([1 => 3, 2 => 3, 3 => 2]); |
|
733 | } |
|
734 | ||
735 | function it_can_replace_items_by_items_from_another_collection() |
|
736 | { |
|
737 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
738 | ||
739 | $this |
|
740 | ->replace([3 => 'a']) |
|
741 | ->toArray() |
|
742 | ->shouldReturn([1, 'a', 'a', 2]); |
|
743 | } |
|
744 | ||
745 | function it_can_get_reduction_steps() |
|
746 | { |
|
@@ 745-758 (lines=14) @@ | ||
742 | ->shouldReturn([1, 'a', 'a', 2]); |
|
743 | } |
|
744 | ||
745 | function it_can_get_reduction_steps() |
|
746 | { |
|
747 | $this->beConstructedWith([1, 3, 3, 2,]); |
|
748 | ||
749 | $this |
|
750 | ->reductions( |
|
751 | function ($tmp, $i) { |
|
752 | return $tmp + $i; |
|
753 | }, |
|
754 | 0 |
|
755 | ) |
|
756 | ->toArray() |
|
757 | ->shouldReturn([0, 1, 4, 7, 9]); |
|
758 | } |
|
759 | ||
760 | function it_can_return_every_nth_item() |
|
761 | { |