Code Duplication    Length = 19-20 lines in 4 locations

tests/unit/NodeCollectionTest.php 4 locations

@@ 104-122 (lines=19) @@
101
        static::assertSame($second, $collection->last());
102
    }
103
104
    public function testFirstWithCallbackWillReturnTheFirstThatMatches()
105
    {
106
        $first = m::mock(NodeInterface::class);
107
        $second = m::mock(NodeInterface::class);
108
        $third = m::mock(NodeInterface::class);
109
110
        $first->shouldReceive('thisOne')
111
              ->andReturn(false);
112
        $second->shouldReceive('thisOne')
113
               ->andReturn(true);
114
        $third->shouldReceive('thosOne')
115
              ->andReturn(true);
116
117
        $collection = new NodeCollection([$first, $second, $third]);
118
119
        static::assertSame($second, $collection->first(function ($item) {
120
            return $item->thisOne();
121
        }));
122
    }
123
124
    public function testLastWithCallbackWillReturnTheFirstThatMatches()
125
    {
@@ 124-142 (lines=19) @@
121
        }));
122
    }
123
124
    public function testLastWithCallbackWillReturnTheFirstThatMatches()
125
    {
126
        $first = m::mock(NodeInterface::class);
127
        $second = m::mock(NodeInterface::class);
128
        $third = m::mock(NodeInterface::class);
129
130
        $first->shouldReceive('thisOne')
131
              ->andReturn(true);
132
        $second->shouldReceive('thisOne')
133
               ->andReturn(true);
134
        $third->shouldReceive('thisOne')
135
              ->andReturn(false);
136
137
        $collection = new NodeCollection([$first, $second, $third]);
138
139
        static::assertSame($second, $collection->last(function ($item) {
140
            return $item->thisOne();
141
        }));
142
    }
143
144
    public function testFirstWithCallbackWillReturnDefaultIfNoMatchesAreFound()
145
    {
@@ 144-163 (lines=20) @@
141
        }));
142
    }
143
144
    public function testFirstWithCallbackWillReturnDefaultIfNoMatchesAreFound()
145
    {
146
        $first = m::mock(NodeInterface::class);
147
        $second = m::mock(NodeInterface::class);
148
        $default = m::mock(NodeInterface::class);
149
150
        $first->shouldReceive('thisOne')
151
              ->andReturn(false);
152
        $second->shouldReceive('thisOne')
153
               ->andReturn(false);
154
155
        $collection = new NodeCollection([$first, $second]);
156
157
        static::assertSame($default, $collection->first(function ($item) {
158
            return $item->thisOne();
159
        }, $default));
160
        static::assertNull($collection->first(function ($item) {
161
            return $item->thisOne();
162
        }));
163
    }
164
165
    public function testLastWithCallbackWillReturnDefaultIfNoMatchesAreFound()
166
    {
@@ 165-184 (lines=20) @@
162
        }));
163
    }
164
165
    public function testLastWithCallbackWillReturnDefaultIfNoMatchesAreFound()
166
    {
167
        $first = m::mock(NodeInterface::class);
168
        $second = m::mock(NodeInterface::class);
169
        $default = m::mock(NodeInterface::class);
170
171
        $first->shouldReceive('thisOne')
172
              ->andReturn(false);
173
        $second->shouldReceive('thisOne')
174
               ->andReturn(false);
175
176
        $collection = new NodeCollection([$first, $second]);
177
178
        static::assertSame($default, $collection->last(function ($item) {
179
            return $item->thisOne();
180
        }, $default));
181
        static::assertNull($collection->last(function ($item) {
182
            return $item->thisOne();
183
        }));
184
    }
185
186
    public function testCloneWillCloneTheChildObjects()
187
    {