Code Duplication    Length = 46-52 lines in 5 locations

eZ/Publish/Core/Persistence/Cache/Tests/ContentLanguageHandlerTest.php 1 location

@@ 104-155 (lines=52) @@
101
    /**
102
     * @covers eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::load
103
     */
104
    public function testLoadCacheIsMiss()
105
    {
106
        $this->loggerMock->expects($this->once())->method('logCall');
107
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
108
        $this->cacheMock
109
            ->expects($this->once())
110
            ->method('getItem')
111
            ->with('language', 2)
112
            ->will($this->returnValue($cacheItemMock));
113
114
        $cacheItemMock
115
            ->expects($this->once())
116
            ->method('get')
117
            ->will($this->returnValue(null));
118
119
        $cacheItemMock
120
            ->expects($this->once())
121
            ->method('isMiss')
122
            ->will($this->returnValue(true));
123
124
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Language\\Handler');
125
        $this->persistenceHandlerMock
126
            ->expects($this->once())
127
            ->method('contentLanguageHandler')
128
            ->will($this->returnValue($innerHandlerMock));
129
130
        $innerHandlerMock
131
            ->expects($this->once())
132
            ->method('load')
133
            ->with(2)
134
            ->will(
135
                $this->returnValue(
136
                    new SPILanguage(
137
                        array('id' => 2, 'name' => 'English (UK)', 'languageCode' => 'eng-GB')
138
                    )
139
                )
140
            );
141
142
        $cacheItemMock
143
            ->expects($this->once())
144
            ->method('set')
145
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Language'))
146
            ->will($this->returnValue($cacheItemMock));
147
148
        $cacheItemMock
149
            ->expects($this->once())
150
            ->method('save')
151
            ->with();
152
153
        $handler = $this->persistenceCacheHandler->contentLanguageHandler();
154
        $handler->load(2);
155
    }
156
157
    /**
158
     * @covers eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::load

eZ/Publish/Core/Persistence/Cache/Tests/ContentTypeHandlerTest.php 1 location

@@ 344-395 (lines=52) @@
341
    /**
342
     * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load
343
     */
344
    public function testLoadCacheIsMiss()
345
    {
346
        $this->loggerMock->expects($this->once())->method('logCall');
347
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
348
        $this->cacheMock
349
            ->expects($this->once())
350
            ->method('getItem')
351
            ->with('contentType', 55)
352
            ->will($this->returnValue($cacheItemMock));
353
354
        $cacheItemMock
355
            ->expects($this->once())
356
            ->method('get')
357
            ->will($this->returnValue(null));
358
359
        $cacheItemMock
360
            ->expects($this->once())
361
            ->method('isMiss')
362
            ->will($this->returnValue(true));
363
364
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\Handler');
365
        $this->persistenceHandlerMock
366
            ->expects($this->once())
367
            ->method('contentTypeHandler')
368
            ->will($this->returnValue($innerHandlerMock));
369
370
        $innerHandlerMock
371
            ->expects($this->once())
372
            ->method('load')
373
            ->with(55)
374
            ->will(
375
                $this->returnValue(
376
                    new SPIType(
377
                        array('id' => 55, 'name' => 'Forum', 'identifier' => 'forum')
378
                    )
379
                )
380
            );
381
382
        $cacheItemMock
383
            ->expects($this->once())
384
            ->method('set')
385
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type'))
386
            ->will($this->returnValue($cacheItemMock));
387
388
        $cacheItemMock
389
            ->expects($this->once())
390
            ->method('save')
391
            ->with();
392
393
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
394
        $handler->load(55);
395
    }
396
397
    /**
398
     * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load

eZ/Publish/Core/Persistence/Cache/Tests/LocationHandlerTest.php 2 locations

@@ 218-263 (lines=46) @@
215
    /**
216
     * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent
217
     */
218
    public function testLoadParentLocationsForDraftContentIsMiss()
219
    {
220
        $this->loggerMock->expects($this->once())->method('logCall');
221
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
222
        $this->cacheMock
223
            ->expects($this->once())
224
            ->method('getItem')
225
            ->with('content', 'locations', '44', 'parentLocationsForDraftContent')
226
            ->will($this->returnValue($cacheItemMock));
227
228
        $cacheItemMock
229
            ->expects($this->once())
230
            ->method('get')
231
            ->will($this->returnValue(null));
232
233
        $cacheItemMock
234
            ->expects($this->once())
235
            ->method('isMiss')
236
            ->will($this->returnValue(true));
237
238
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Handler');
239
        $this->persistenceHandlerMock
240
            ->expects($this->once())
241
            ->method('locationHandler')
242
            ->will($this->returnValue($innerHandlerMock));
243
244
        $innerHandlerMock
245
            ->expects($this->once())
246
            ->method('loadParentLocationsForDraftContent')
247
            ->with(44)
248
            ->will($this->returnValue(array(new Location(array('id' => 33)))));
249
250
        $cacheItemMock
251
            ->expects($this->once())
252
            ->method('set')
253
            ->with(array(33))
254
            ->will($this->returnValue($cacheItemMock));
255
256
        $cacheItemMock
257
            ->expects($this->once())
258
            ->method('save')
259
            ->with();
260
261
        $handler = $this->persistenceCacheHandler->locationHandler();
262
        $handler->loadParentLocationsForDraftContent(44);
263
    }
264
265
    /**
266
     * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent
@@ 326-371 (lines=46) @@
323
    /**
324
     * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent
325
     */
326
    public function testLoadLocationsByContentWithRootIsMiss()
327
    {
328
        $this->loggerMock->expects($this->once())->method('logCall');
329
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
330
        $this->cacheMock
331
            ->expects($this->once())
332
            ->method('getItem')
333
            ->with('content', 'locations', '44', 'root', '2')
334
            ->will($this->returnValue($cacheItemMock));
335
336
        $cacheItemMock
337
            ->expects($this->once())
338
            ->method('get')
339
            ->will($this->returnValue(null));
340
341
        $cacheItemMock
342
            ->expects($this->once())
343
            ->method('isMiss')
344
            ->will($this->returnValue(true));
345
346
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Handler');
347
        $this->persistenceHandlerMock
348
            ->expects($this->once())
349
            ->method('locationHandler')
350
            ->will($this->returnValue($innerHandlerMock));
351
352
        $innerHandlerMock
353
            ->expects($this->once())
354
            ->method('loadLocationsByContent')
355
            ->with(44, 2)
356
            ->will($this->returnValue(array(new Location(array('id' => 33)))));
357
358
        $cacheItemMock
359
            ->expects($this->once())
360
            ->method('set')
361
            ->with(array(33))
362
            ->will($this->returnValue($cacheItemMock));
363
364
        $cacheItemMock
365
            ->expects($this->once())
366
            ->method('save')
367
            ->with();
368
369
        $handler = $this->persistenceCacheHandler->locationHandler();
370
        $handler->loadLocationsByContent(44, 2);
371
    }
372
373
    /**
374
     * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent

eZ/Publish/Core/Persistence/Cache/Tests/SectionHandlerTest.php 1 location

@@ 218-269 (lines=52) @@
215
    /**
216
     * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::load
217
     */
218
    public function testLoadCacheIsMiss()
219
    {
220
        $this->loggerMock->expects($this->once())->method('logCall');
221
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
222
        $this->cacheMock
223
            ->expects($this->once())
224
            ->method('getItem')
225
            ->with('section', 33)
226
            ->will($this->returnValue($cacheItemMock));
227
228
        $cacheItemMock
229
            ->expects($this->once())
230
            ->method('isMiss')
231
            ->will($this->returnValue(true));
232
233
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Section\\Handler');
234
        $this->persistenceHandlerMock
235
            ->expects($this->once())
236
            ->method('sectionHandler')
237
            ->will($this->returnValue($innerHandlerMock));
238
239
        $innerHandlerMock
240
            ->expects($this->once())
241
            ->method('load')
242
            ->with(33)
243
            ->will(
244
                $this->returnValue(
245
                    new SPISection(
246
                        array('id' => 33, 'name' => 'Intranet', 'identifier' => 'intranet')
247
                    )
248
                )
249
            );
250
251
        $cacheItemMock
252
            ->expects($this->once())
253
            ->method('set')
254
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Section'))
255
            ->will($this->returnValue($cacheItemMock));
256
257
        $cacheItemMock
258
            ->expects($this->once())
259
            ->method('save')
260
            ->with();
261
262
        $cacheItemMock
263
            ->expects($this->once())
264
            ->method('get')
265
            ->will($this->returnValue(null));
266
267
        $handler = $this->persistenceCacheHandler->sectionHandler();
268
        $handler->load(33);
269
    }
270
271
    /**
272
     * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::load