Code Duplication    Length = 55-55 lines in 2 locations

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

@@ 370-424 (lines=55) @@
367
    /**
368
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
369
     */
370
    public function testListURLAliasesForLocationIsMiss()
371
    {
372
        $this->loggerMock->expects($this->once())->method('logCall');
373
374
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
375
        $this->cacheMock
376
            ->expects($this->once())
377
            ->method('getItem')
378
            ->with('urlAlias', 'location', 44)
379
            ->will($this->returnValue($cacheItemMock));
380
381
        $cacheItemMock
382
            ->expects($this->once())
383
            ->method('get')
384
            ->will($this->returnValue(null));
385
386
        $cacheItemMock
387
            ->expects($this->once())
388
            ->method('isMiss')
389
            ->will($this->returnValue(true));
390
391
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler');
392
        $this->persistenceHandlerMock
393
            ->expects($this->once())
394
            ->method('urlAliasHandler')
395
            ->will($this->returnValue($innerHandler));
396
397
        $innerHandler
398
            ->expects($this->once())
399
            ->method('listURLAliasesForLocation')
400
            ->with(44, false)
401
            ->will(
402
                $this->returnValue(
403
                    array(
404
                        new UrlAlias(array('id' => 55)),
405
                        new UrlAlias(array('id' => 58)),
406
                        new UrlAlias(array('id' => 91)),
407
                    )
408
                )
409
            );
410
411
        $cacheItemMock
412
            ->expects($this->once())
413
            ->method('set')
414
            ->with(array(55, 58, 91))
415
            ->will($this->returnValue($cacheItemMock));
416
417
        $cacheItemMock
418
            ->expects($this->once())
419
            ->method('save')
420
            ->with();
421
422
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
423
        $handler->listURLAliasesForLocation(44, false);
424
    }
425
426
    /**
427
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
@@ 429-483 (lines=55) @@
426
    /**
427
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
428
     */
429
    public function testListURLAliasesForLocationCustomIsMiss()
430
    {
431
        $this->loggerMock->expects($this->once())->method('logCall');
432
433
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
434
        $this->cacheMock
435
            ->expects($this->once())
436
            ->method('getItem')
437
            ->with('urlAlias', 'location', '44', 'custom')
438
            ->will($this->returnValue($cacheItemMock));
439
440
        $cacheItemMock
441
            ->expects($this->once())
442
            ->method('get')
443
            ->will($this->returnValue(null));
444
445
        $cacheItemMock
446
            ->expects($this->once())
447
            ->method('isMiss')
448
            ->will($this->returnValue(true));
449
450
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler');
451
        $this->persistenceHandlerMock
452
            ->expects($this->once())
453
            ->method('urlAliasHandler')
454
            ->will($this->returnValue($innerHandler));
455
456
        $innerHandler
457
            ->expects($this->once())
458
            ->method('listURLAliasesForLocation')
459
            ->with(44, true)
460
            ->will(
461
                $this->returnValue(
462
                    array(
463
                        new UrlAlias(array('id' => 55)),
464
                        new UrlAlias(array('id' => 58)),
465
                        new UrlAlias(array('id' => 91)),
466
                    )
467
                )
468
            );
469
470
        $cacheItemMock
471
            ->expects($this->once())
472
            ->method('set')
473
            ->with(array(55, 58, 91))
474
            ->will($this->returnValue($cacheItemMock));
475
476
        $cacheItemMock
477
            ->expects($this->once())
478
            ->method('save')
479
            ->with();
480
481
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
482
        $handler->listURLAliasesForLocation(44, true);
483
    }
484
485
    /**
486
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation