TYPO3 CMS  TYPO3_7-6
CacheServiceTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $cacheService;
26 
30  protected $cacheManagerMock;
31 
32  protected function setUp()
33  {
34  $this->cacheService = new \TYPO3\CMS\Extbase\Service\CacheService();
35  $this->cacheManagerMock = $this->getMock(\TYPO3\CMS\Core\Cache\CacheManager::class);
36  $this->cacheService->injectCacheManager($this->cacheManagerMock);
37  }
38 
43  {
44  $this->cacheManagerMock->expects($this->once())->method('flushCachesInGroupByTag')->with('pages', 'pageId_123');
45  $this->cacheService->clearPageCache(123);
46  }
47 
52  {
53  $this->cacheManagerMock->expects($this->once())->method('flushCachesInGroupByTag')->with('pages', 'pageId_0');
54  $this->cacheService->clearPageCache('Foo');
55  }
56 
61  {
62  $this->cacheManagerMock->expects($this->once())->method('flushCachesInGroup')->with('pages');
63  $this->cacheService->clearPageCache();
64  }
65 
70  {
71  $this->cacheManagerMock->expects($this->at(0))->method('flushCachesInGroupByTag')->with('pages', 'pageId_1');
72  $this->cacheManagerMock->expects($this->at(1))->method('flushCachesInGroupByTag')->with('pages', 'pageId_2');
73  $this->cacheManagerMock->expects($this->at(2))->method('flushCachesInGroupByTag')->with('pages', 'pageId_3');
74  $this->cacheService->clearPageCache([1, 2, 3]);
75  }
76 
81  {
82  $this->cacheManagerMock->expects($this->at(0))->method('flushCachesInGroupByTag')->with('pages', 'pageId_2');
83  $this->cacheManagerMock->expects($this->at(1))->method('flushCachesInGroupByTag')->with('pages', 'pageId_15');
84  $this->cacheManagerMock->expects($this->at(2))->method('flushCachesInGroupByTag')->with('pages', 'pageId_8');
85 
86  $this->cacheService->getPageIdStack()->push(8);
87  $this->cacheService->getPageIdStack()->push(15);
88  $this->cacheService->getPageIdStack()->push(2);
89 
90  $this->cacheService->clearCachesOfRegisteredPageIds();
91  }
92 
97  {
98  $this->cacheManagerMock->expects($this->at(0))->method('flushCachesInGroupByTag')->with('pages', 'pageId_2');
99  $this->cacheManagerMock->expects($this->at(1))->method('flushCachesInGroupByTag')->with('pages', 'pageId_15');
100  $this->cacheManagerMock->expects($this->at(2))->method('flushCachesInGroupByTag')->with('pages', 'pageId_8');
101  $this->cacheManagerMock->expects($this->exactly(3))->method('flushCachesInGroupByTag');
102 
103  $this->cacheService->getPageIdStack()->push(8);
104  $this->cacheService->getPageIdStack()->push(15);
105  $this->cacheService->getPageIdStack()->push(15);
106  $this->cacheService->getPageIdStack()->push(2);
107  $this->cacheService->getPageIdStack()->push(2);
108 
109  $this->cacheService->clearCachesOfRegisteredPageIds();
110  }
111 }