Code Duplication    Length = 32-32 lines in 2 locations

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

@@ 156-187 (lines=32) @@
153
     *
154
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Mapper
155
     */
156
    protected function getContentMapperMock()
157
    {
158
        $mapperMock = $this->getMock(
159
            'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Mapper',
160
            array('extractContentInfoFromRows'),
161
            array(
162
                $this->getFieldRegistry(),
163
                $this->getLanguageHandler(),
164
            )
165
        );
166
        $mapperMock->expects($this->any())
167
            ->method('extractContentInfoFromRows')
168
            ->with($this->isType('array'))
169
            ->will(
170
                $this->returnCallback(
171
                    function ($rows) {
172
                        $contentInfoObjs = array();
173
                        foreach ($rows as $row) {
174
                            $contentId = (int)$row['id'];
175
                            if (!isset($contentInfoObjs[$contentId])) {
176
                                $contentInfoObjs[$contentId] = new ContentInfo();
177
                                $contentInfoObjs[$contentId]->id = $contentId;
178
                            }
179
                        }
180
181
                        return array_values($contentInfoObjs);
182
                    }
183
                )
184
            );
185
186
        return $mapperMock;
187
    }
188
189
    /**
190
     * Returns a field registry mock object.

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

@@ 278-309 (lines=32) @@
275
     *
276
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Mapper
277
     */
278
    protected function getContentMapperMock()
279
    {
280
        $mapperMock = $this->getMock(
281
            'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Mapper',
282
            array('extractContentInfoFromRows'),
283
            array(
284
                $this->fieldRegistry,
285
                $this->getLanguageHandler(),
286
            )
287
        );
288
        $mapperMock->expects($this->any())
289
            ->method('extractContentInfoFromRows')
290
            ->with($this->isType('array'))
291
            ->will(
292
                $this->returnCallback(
293
                    function ($rows) {
294
                        $contentInfoObjs = array();
295
                        foreach ($rows as $row) {
296
                            $contentId = (int)$row['id'];
297
                            if (!isset($contentInfoObjs[$contentId])) {
298
                                $contentInfoObjs[$contentId] = new ContentInfo();
299
                                $contentInfoObjs[$contentId]->id = $contentId;
300
                            }
301
                        }
302
303
                        return array_values($contentInfoObjs);
304
                    }
305
                )
306
            );
307
308
        return $mapperMock;
309
    }
310
311
    /**
312
     * Returns a content field handler mock.