Code Duplication    Length = 37-38 lines in 4 locations

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

@@ 160-196 (lines=37) @@
157
    /**
158
     * @covers eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::load
159
     */
160
    public function testLoadHasCache()
161
    {
162
        $this->loggerMock->expects($this->never())->method($this->anything());
163
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
164
        $this->cacheMock
165
            ->expects($this->once())
166
            ->method('getItem')
167
            ->with('language', 2)
168
            ->will($this->returnValue($cacheItemMock));
169
170
        $cacheItemMock
171
            ->expects($this->once())
172
            ->method('get')
173
            ->will(
174
                $this->returnValue(
175
                    new SPILanguage(
176
                        array('id' => 2, 'name' => 'English (UK)', 'languageCode' => 'eng-GB')
177
                    )
178
                )
179
            );
180
181
        $cacheItemMock
182
            ->expects($this->once())
183
            ->method('isMiss')
184
            ->will($this->returnValue(false));
185
186
        $this->persistenceHandlerMock
187
            ->expects($this->never())
188
            ->method('contentLanguageHandler');
189
190
        $cacheItemMock
191
            ->expects($this->never())
192
            ->method('set');
193
194
        $handler = $this->persistenceCacheHandler->contentLanguageHandler();
195
        $handler->load(2);
196
    }
197
198
    /**
199
     * @covers eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::loadAll

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

@@ 400-436 (lines=37) @@
397
    /**
398
     * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load
399
     */
400
    public function testLoadHasCache()
401
    {
402
        $this->loggerMock->expects($this->never())->method($this->anything());
403
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
404
        $this->cacheMock
405
            ->expects($this->once())
406
            ->method('getItem')
407
            ->with('contentType', 55)
408
            ->will($this->returnValue($cacheItemMock));
409
410
        $cacheItemMock
411
            ->expects($this->once())
412
            ->method('isMiss')
413
            ->will($this->returnValue(false));
414
415
        $this->persistenceHandlerMock
416
            ->expects($this->never())
417
            ->method('contentTypeHandler');
418
419
        $cacheItemMock
420
            ->expects($this->once())
421
            ->method('get')
422
            ->will(
423
                $this->returnValue(
424
                    new SPIType(
425
                        array('id' => 55, 'name' => 'Forum', 'identifier' => 'forum')
426
                    )
427
                )
428
            );
429
430
        $cacheItemMock
431
            ->expects($this->never())
432
            ->method('set');
433
434
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
435
        $handler->load(55);
436
    }
437
438
    /**
439
     * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadByIdentifier

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

@@ 274-310 (lines=37) @@
271
    /**
272
     * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::load
273
     */
274
    public function testLoadHasCache()
275
    {
276
        $this->loggerMock->expects($this->never())->method($this->anything());
277
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
278
        $this->cacheMock
279
            ->expects($this->once())
280
            ->method('getItem')
281
            ->with('section', 33)
282
            ->will($this->returnValue($cacheItemMock));
283
284
        $cacheItemMock
285
            ->expects($this->once())
286
            ->method('isMiss')
287
            ->will($this->returnValue(false));
288
289
        $this->persistenceHandlerMock
290
            ->expects($this->never())
291
            ->method('sectionHandler');
292
293
        $cacheItemMock
294
            ->expects($this->once())
295
            ->method('get')
296
            ->will(
297
                $this->returnValue(
298
                    new SPISection(
299
                        array('id' => 33, 'name' => 'Intranet', 'identifier' => 'intranet')
300
                    )
301
                )
302
            );
303
304
        $cacheItemMock
305
            ->expects($this->never())
306
            ->method('set');
307
308
        $handler = $this->persistenceCacheHandler->sectionHandler();
309
        $handler->load(33);
310
    }
311
312
    /**
313
     * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::loadAll

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

@@ 490-527 (lines=38) @@
487
    /**
488
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::createRole
489
     */
490
    public function testCreateRole()
491
    {
492
        $this->loggerMock->expects($this->once())->method('logCall');
493
494
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler');
495
        $this->persistenceHandlerMock
496
            ->expects($this->once())
497
            ->method('userHandler')
498
            ->will($this->returnValue($innerHandlerMock));
499
500
        $innerHandlerMock
501
            ->expects($this->once())
502
            ->method('createRole')
503
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\RoleCreateStruct'))
504
            ->will(
505
                $this->returnValue(
506
                    new Role(
507
                        ['id' => 33, 'name' => 'Editors', 'identifier' => 'intranet', 'status' => Role::STATUS_DEFINED]
508
                    )
509
                )
510
            );
511
512
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
513
        $this->cacheMock
514
            ->expects($this->never())
515
            ->method('getItem');
516
517
        $cacheItemMock
518
            ->expects($this->never())
519
            ->method('set');
520
521
        $cacheItemMock
522
            ->expects($this->never())
523
            ->method('get');
524
525
        $handler = $this->persistenceCacheHandler->userHandler();
526
        $handler->createRole(new User\RoleCreateStruct());
527
    }
528
529
    /**
530
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::createRoleDraft