Code Duplication    Length = 29-29 lines in 2 locations

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

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

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

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