TYPO3 CMS  TYPO3_7-6
BootstrapTest.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 {
23  // Tests concerning loadCachedTCA
25 
29  public function loadCachedTcaRequiresCacheFileIfCacheEntryExists()
30  {
32  $bootstrapInstance = $this->getAccessibleMock(
33  \TYPO3\CMS\Core\Core\Bootstrap::class,
34  ['dummy'],
35  [],
36  '',
37  false
38  );
39  $mockCache = $this->getMock(
40  \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class,
41  ['getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'],
42  [],
43  '',
44  false
45  );
46  $mockCacheManager = $this->getMock(
47  \TYPO3\CMS\Core\Cache\CacheManager::class,
48  ['getCache']
49  );
50  $mockCacheManager
51  ->expects($this->any())
52  ->method('getCache')
53  ->will($this->returnValue($mockCache));
54  $mockCache
55  ->expects($this->any())
56  ->method('has')
57  ->will($this->returnValue(true));
58  $mockCache
59  ->expects($this->once())
60  ->method('get');
61  $bootstrapInstance->setEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $mockCacheManager);
62  $bootstrapInstance->loadCachedTca();
63  }
64 
68  public function loadCachedTcaSetsCacheEntryIfNoCacheEntryExists()
69  {
71  $bootstrapInstance = $this->getAccessibleMock(
72  \TYPO3\CMS\Core\Core\Bootstrap::class,
73  ['loadExtensionTables'],
74  [],
75  '',
76  false
77  );
78  $mockCache = $this->getMock(
79  \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class,
80  ['getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'],
81  [],
82  '',
83  false
84  );
85  $mockCacheManager = $this->getMock(
86  \TYPO3\CMS\Core\Cache\CacheManager::class,
87  ['getCache']
88  );
89  $mockCacheManager
90  ->expects($this->any())
91  ->method('getCache')
92  ->will($this->returnValue($mockCache));
93  $mockCache
94  ->expects($this->any())
95  ->method('has')
96  ->will($this->returnValue(false));
97  $mockCache
98  ->expects($this->once())
99  ->method('set');
100  $bootstrapInstance->setEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $mockCacheManager);
101  $bootstrapInstance->loadCachedTca();
102  }
103 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)