TYPO3 CMS  TYPO3_6-2
CacheServiceTest.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $cacheService;
26 
30  protected $cacheManagerMock;
31 
32  public function setUp() {
33  $this->cacheService = new \TYPO3\CMS\Extbase\Service\CacheService();
34  $this->cacheManagerMock = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager');
35  $this->cacheService->injectCacheManager($this->cacheManagerMock);
36  }
37 
42  $this->cacheManagerMock->expects($this->once())->method('flushCachesInGroupByTag')->with('pages', 'pageId_123');
43  $this->cacheService->clearPageCache(123);
44  }
45 
50  $this->cacheManagerMock->expects($this->once())->method('flushCachesInGroupByTag')->with('pages', 'pageId_0');
51  $this->cacheService->clearPageCache('Foo');
52  }
53 
58  $this->cacheManagerMock->expects($this->once())->method('flushCachesInGroup')->with('pages');
59  $this->cacheService->clearPageCache();
60  }
61 
66  $this->cacheManagerMock->expects($this->at(0))->method('flushCachesInGroupByTag')->with('pages', 'pageId_1');
67  $this->cacheManagerMock->expects($this->at(1))->method('flushCachesInGroupByTag')->with('pages', 'pageId_2');
68  $this->cacheManagerMock->expects($this->at(2))->method('flushCachesInGroupByTag')->with('pages', 'pageId_3');
69  $this->cacheService->clearPageCache(array(1, 2, 3));
70  }
71 
76  public function clearsCachesOfRegisteredPageIds() {
77  $this->cacheManagerMock->expects($this->at(0))->method('flushCachesInGroupByTag')->with('pages', 'pageId_2');
78  $this->cacheManagerMock->expects($this->at(1))->method('flushCachesInGroupByTag')->with('pages', 'pageId_15');
79  $this->cacheManagerMock->expects($this->at(2))->method('flushCachesInGroupByTag')->with('pages', 'pageId_8');
80 
81  $this->cacheService->getPageIdStack()->push(8);
82  $this->cacheService->getPageIdStack()->push(15);
83  $this->cacheService->getPageIdStack()->push(2);
84 
85  $this->cacheService->clearCachesOfRegisteredPageIds();
86  }
87 
93  $this->cacheManagerMock->expects($this->at(0))->method('flushCachesInGroupByTag')->with('pages', 'pageId_2');
94  $this->cacheManagerMock->expects($this->at(1))->method('flushCachesInGroupByTag')->with('pages', 'pageId_15');
95  $this->cacheManagerMock->expects($this->at(2))->method('flushCachesInGroupByTag')->with('pages', 'pageId_8');
96  $this->cacheManagerMock->expects($this->exactly(3))->method('flushCachesInGroupByTag');
97 
98  $this->cacheService->getPageIdStack()->push(8);
99  $this->cacheService->getPageIdStack()->push(15);
100  $this->cacheService->getPageIdStack()->push(15);
101  $this->cacheService->getPageIdStack()->push(2);
102  $this->cacheService->getPageIdStack()->push(2);
103 
104  $this->cacheService->clearCachesOfRegisteredPageIds();
105  }
106 }