Code Duplication    Length = 55-55 lines in 2 locations

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

@@ 301-355 (lines=55) @@
298
    /**
299
     * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
300
     */
301
    public function testListURLAliasesForLocationIsMiss()
302
    {
303
        $this->loggerMock->expects($this->once())->method('logCall');
304
305
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
306
        $this->cacheMock
307
            ->expects($this->once())
308
            ->method('getItem')
309
            ->with('urlAlias', 'location', 44)
310
            ->will($this->returnValue($cacheItemMock));
311
312
        $cacheItemMock
313
            ->expects($this->once())
314
            ->method('get')
315
            ->will($this->returnValue(null));
316
317
        $cacheItemMock
318
            ->expects($this->once())
319
            ->method('isMiss')
320
            ->will($this->returnValue(true));
321
322
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler');
323
        $this->persistenceHandlerMock
324
            ->expects($this->once())
325
            ->method('urlAliasHandler')
326
            ->will($this->returnValue($innerHandler));
327
328
        $innerHandler
329
            ->expects($this->once())
330
            ->method('listURLAliasesForLocation')
331
            ->with(44, false)
332
            ->will(
333
                $this->returnValue(
334
                    array(
335
                        new UrlAlias(array('id' => 55)),
336
                        new UrlAlias(array('id' => 58)),
337
                        new UrlAlias(array('id' => 91)),
338
                    )
339
                )
340
            );
341
342
        $cacheItemMock
343
            ->expects($this->once())
344
            ->method('set')
345
            ->with(array(55, 58, 91))
346
            ->will($this->returnValue($cacheItemMock));
347
348
        $cacheItemMock
349
            ->expects($this->once())
350
            ->method('save')
351
            ->with();
352
353
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
354
        $handler->listURLAliasesForLocation(44, false);
355
    }
356
357
    /**
358
     * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
@@ 360-414 (lines=55) @@
357
    /**
358
     * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
359
     */
360
    public function testListURLAliasesForLocationCustomIsMiss()
361
    {
362
        $this->loggerMock->expects($this->once())->method('logCall');
363
364
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
365
        $this->cacheMock
366
            ->expects($this->once())
367
            ->method('getItem')
368
            ->with('urlAlias', 'location', '44', 'custom')
369
            ->will($this->returnValue($cacheItemMock));
370
371
        $cacheItemMock
372
            ->expects($this->once())
373
            ->method('get')
374
            ->will($this->returnValue(null));
375
376
        $cacheItemMock
377
            ->expects($this->once())
378
            ->method('isMiss')
379
            ->will($this->returnValue(true));
380
381
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler');
382
        $this->persistenceHandlerMock
383
            ->expects($this->once())
384
            ->method('urlAliasHandler')
385
            ->will($this->returnValue($innerHandler));
386
387
        $innerHandler
388
            ->expects($this->once())
389
            ->method('listURLAliasesForLocation')
390
            ->with(44, true)
391
            ->will(
392
                $this->returnValue(
393
                    array(
394
                        new UrlAlias(array('id' => 55)),
395
                        new UrlAlias(array('id' => 58)),
396
                        new UrlAlias(array('id' => 91)),
397
                    )
398
                )
399
            );
400
401
        $cacheItemMock
402
            ->expects($this->once())
403
            ->method('set')
404
            ->with(array(55, 58, 91))
405
            ->will($this->returnValue($cacheItemMock));
406
407
        $cacheItemMock
408
            ->expects($this->once())
409
            ->method('save')
410
            ->with();
411
412
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
413
        $handler->listURLAliasesForLocation(44, true);
414
    }
415
416
    /**
417
     * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation