Code Duplication    Length = 53-54 lines in 4 locations

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

@@ 158-211 (lines=54) @@
155
    /**
156
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent
157
     */
158
    public function testLoadLocationsByContentHasCache()
159
    {
160
        $this->loggerMock->expects($this->never())->method($this->anything());
161
162
        $this->persistenceHandlerMock
163
            ->expects($this->never())
164
            ->method($this->anything());
165
166
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
167
        $this->cacheMock
168
            ->expects($this->at(0))
169
            ->method('getItem')
170
            ->with('content', 'locations', 44)
171
            ->will($this->returnValue($cacheItemMock));
172
173
        $cacheItemMock
174
            ->expects($this->once())
175
            ->method('get')
176
            ->will($this->returnValue(array(33)));
177
178
        $cacheItemMock
179
            ->expects($this->once())
180
            ->method('isMiss')
181
            ->will($this->returnValue(false));
182
183
        $cacheItemMock
184
            ->expects($this->never())
185
            ->method('set');
186
187
        // inline call to load()
188
        $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface');
189
        $this->cacheMock
190
            ->expects($this->at(1))
191
            ->method('getItem')
192
            ->with('location', 33)
193
            ->will($this->returnValue($cacheItemMock2));
194
195
        $cacheItemMock2
196
            ->expects($this->once())
197
            ->method('get')
198
            ->will($this->returnValue(new Location(array('id' => 33))));
199
200
        $cacheItemMock2
201
            ->expects($this->once())
202
            ->method('isMiss')
203
            ->will($this->returnValue(false));
204
205
        $cacheItemMock2
206
            ->expects($this->never())
207
            ->method('set');
208
209
        $handler = $this->persistenceCacheHandler->locationHandler();
210
        $handler->loadLocationsByContent(44);
211
    }
212
213
    /**
214
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent
@@ 266-319 (lines=54) @@
263
    /**
264
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent
265
     */
266
    public function testLoadParentLocationsForDraftContentHasCache()
267
    {
268
        $this->loggerMock->expects($this->never())->method($this->anything());
269
270
        $this->persistenceHandlerMock
271
            ->expects($this->never())
272
            ->method($this->anything());
273
274
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
275
        $this->cacheMock
276
            ->expects($this->at(0))
277
            ->method('getItem')
278
            ->with('content', 'locations', '44', 'parentLocationsForDraftContent')
279
            ->will($this->returnValue($cacheItemMock));
280
281
        $cacheItemMock
282
            ->expects($this->once())
283
            ->method('get')
284
            ->will($this->returnValue(array(33)));
285
286
        $cacheItemMock
287
            ->expects($this->once())
288
            ->method('isMiss')
289
            ->will($this->returnValue(false));
290
291
        $cacheItemMock
292
            ->expects($this->never())
293
            ->method('set');
294
295
        // inline call to load()
296
        $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface');
297
        $this->cacheMock
298
            ->expects($this->at(1))
299
            ->method('getItem')
300
            ->with('location', 33)
301
            ->will($this->returnValue($cacheItemMock2));
302
303
        $cacheItemMock2
304
            ->expects($this->once())
305
            ->method('get')
306
            ->will($this->returnValue(new Location(array('id' => 33))));
307
308
        $cacheItemMock2
309
            ->expects($this->once())
310
            ->method('isMiss')
311
            ->will($this->returnValue(false));
312
313
        $cacheItemMock2
314
            ->expects($this->never())
315
            ->method('set');
316
317
        $handler = $this->persistenceCacheHandler->locationHandler();
318
        $handler->loadParentLocationsForDraftContent(44);
319
    }
320
321
    /**
322
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent
@@ 374-427 (lines=54) @@
371
    /**
372
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent
373
     */
374
    public function testLoadLocationsByContentWithRootHasCache()
375
    {
376
        $this->loggerMock->expects($this->never())->method($this->anything());
377
378
        $this->persistenceHandlerMock
379
            ->expects($this->never())
380
            ->method($this->anything());
381
382
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
383
        $this->cacheMock
384
            ->expects($this->at(0))
385
            ->method('getItem')
386
            ->with('content', 'locations', '44', 'root', '2')
387
            ->will($this->returnValue($cacheItemMock));
388
389
        $cacheItemMock
390
            ->expects($this->once())
391
            ->method('get')
392
            ->will($this->returnValue(array(33)));
393
394
        $cacheItemMock
395
            ->expects($this->once())
396
            ->method('isMiss')
397
            ->will($this->returnValue(false));
398
399
        $cacheItemMock
400
            ->expects($this->never())
401
            ->method('set');
402
403
        // inline call to load()
404
        $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface');
405
        $this->cacheMock
406
            ->expects($this->at(1))
407
            ->method('getItem')
408
            ->with('location', 33)
409
            ->will($this->returnValue($cacheItemMock2));
410
411
        $cacheItemMock2
412
            ->expects($this->once())
413
            ->method('get')
414
            ->will($this->returnValue(new Location(array('id' => 33))));
415
416
        $cacheItemMock2
417
            ->expects($this->once())
418
            ->method('isMiss')
419
            ->will($this->returnValue(false));
420
421
        $cacheItemMock2
422
            ->expects($this->never())
423
            ->method('set');
424
425
        $handler = $this->persistenceCacheHandler->locationHandler();
426
        $handler->loadLocationsByContent(44, 2);
427
    }
428
429
    /**
430
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadByRemoteId

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

@@ 789-841 (lines=53) @@
786
    /**
787
     * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::lookup
788
     */
789
    public function testLookupHasCache()
790
    {
791
        $this->loggerMock->expects($this->never())->method('logCall');
792
793
        $this->persistenceHandlerMock
794
            ->expects($this->never())
795
            ->method($this->anything());
796
797
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
798
        $this->cacheMock
799
            ->expects($this->at(0))
800
            ->method('getItem')
801
            ->with('urlAlias', 'url', '/url')
802
            ->will($this->returnValue($cacheItemMock));
803
804
        $cacheItemMock
805
            ->expects($this->once())
806
            ->method('get')
807
            ->will($this->returnValue(55));
808
809
        $cacheItemMock
810
            ->expects($this->once())
811
            ->method('isMiss')
812
            ->will($this->returnValue(false));
813
814
        $cacheItemMock
815
            ->expects($this->never())
816
            ->method('set');
817
818
        $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface');
819
        $this->cacheMock
820
            ->expects($this->at(1))
821
            ->method('getItem')
822
            ->with('urlAlias', 55)
823
            ->will($this->returnValue($cacheItemMock2));
824
825
        $cacheItemMock2
826
            ->expects($this->once())
827
            ->method('get')
828
            ->will($this->returnValue(new UrlAlias(array('id' => 55))));
829
830
        $cacheItemMock2
831
            ->expects($this->once())
832
            ->method('isMiss')
833
            ->will($this->returnValue(false));
834
835
        $cacheItemMock2
836
            ->expects($this->never())
837
            ->method('set');
838
839
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
840
        $handler->lookup('/url');
841
    }
842
843
    /**
844
     * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::lookup