@@ 47-63 (lines=17) @@ | ||
44 | $collection->add($node); |
|
45 | } |
|
46 | ||
47 | public function testCallingApplyWillModifyTheContentsUsingReference() |
|
48 | { |
|
49 | $node = m::mock(NodeInterface::class); |
|
50 | $node->shouldReceive('someMethod') |
|
51 | ->once() |
|
52 | ->andReturn(null); |
|
53 | ||
54 | $collection = new NodeCollection(); |
|
55 | $collection->add($node); |
|
56 | ||
57 | $collection->apply(function ($item) { |
|
58 | $item->someMethod(); |
|
59 | }); |
|
60 | ||
61 | $item = $collection->getAll()[0]; |
|
62 | static::assertSame($node, $item); |
|
63 | } |
|
64 | ||
65 | public function testCallingApplyWillModifyTheContentsUsingReturnValue() |
|
66 | { |
|
@@ 65-82 (lines=18) @@ | ||
62 | static::assertSame($node, $item); |
|
63 | } |
|
64 | ||
65 | public function testCallingApplyWillModifyTheContentsUsingReturnValue() |
|
66 | { |
|
67 | $node = m::mock(NodeInterface::class); |
|
68 | $node->shouldReceive('someMethod') |
|
69 | ->once() |
|
70 | ->andReturn(null); |
|
71 | ||
72 | $collection = new NodeCollection(); |
|
73 | $collection->add($node); |
|
74 | ||
75 | $collection->apply(function ($item) { |
|
76 | $item->someMethod(); |
|
77 | return $item; |
|
78 | }); |
|
79 | ||
80 | $item = $collection->getAll()[0]; |
|
81 | static::assertSame($node, $item); |
|
82 | } |
|
83 | ||
84 | public function testFirstWithNoCallbackWillReturnTheFirstEntry() |
|
85 | { |