Code Duplication    Length = 29-29 lines in 2 locations

eZ/Publish/Core/Search/Legacy/Tests/Content/HandlerLocationSortTest.php 1 location

@@ 187-215 (lines=29) @@
184
     *
185
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper
186
     */
187
    protected function getLocationMapperMock()
188
    {
189
        $mapperMock = $this->getMock(
190
            'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Location\\Mapper',
191
            ['createLocationsFromRows']
192
        );
193
        $mapperMock
194
            ->expects($this->any())
195
            ->method('createLocationsFromRows')
196
            ->with($this->isType('array'))
197
            ->will(
198
                $this->returnCallback(
199
                    function ($rows) {
200
                        $locations = [];
201
                        foreach ($rows as $row) {
202
                            $locationId = (int)$row['node_id'];
203
                            if (!isset($locations[$locationId])) {
204
                                $locations[$locationId] = new SPILocation();
205
                                $locations[$locationId]->id = $locationId;
206
                            }
207
                        }
208
209
                        return array_values($locations);
210
                    }
211
                )
212
            );
213
214
        return $mapperMock;
215
    }
216
217
    public function testNoSorting()
218
    {

eZ/Publish/Core/Search/Legacy/Tests/Content/HandlerLocationTest.php 1 location

@@ 251-279 (lines=29) @@
248
     *
249
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper
250
     */
251
    protected function getLocationMapperMock()
252
    {
253
        $mapperMock = $this->getMock(
254
            'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Location\\Mapper',
255
            ['createLocationsFromRows']
256
        );
257
        $mapperMock
258
            ->expects($this->any())
259
            ->method('createLocationsFromRows')
260
            ->with($this->isType('array'))
261
            ->will(
262
                $this->returnCallback(
263
                    function ($rows) {
264
                        $locations = [];
265
                        foreach ($rows as $row) {
266
                            $locationId = (int)$row['node_id'];
267
                            if (!isset($locations[$locationId])) {
268
                                $locations[$locationId] = new SPILocation();
269
                                $locations[$locationId]->id = $locationId;
270
                            }
271
                        }
272
273
                        return array_values($locations);
274
                    }
275
                )
276
            );
277
278
        return $mapperMock;
279
    }
280
281
    public function testFindWithoutOffsetLimit()
282
    {