Code Duplication    Length = 32-32 lines in 2 locations

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

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

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

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