[TASK] Remove $db property in UserAuthentication classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Core / BootstrapTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Core;
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
17 /**
18 * Testcase
19 */
20 class BootstrapTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
21 {
22 /////////////////////////////////////////
23 // Tests concerning loadCachedTCA
24 /////////////////////////////////////////
25
26 /**
27 * @test
28 */
29 public function loadCachedTcaRequiresCacheFileIfCacheEntryExists()
30 {
31 /** @var $bootstrapInstance \TYPO3\CMS\Core\Core\Bootstrap|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
32 $bootstrapInstance = $this->getAccessibleMock(
33 \TYPO3\CMS\Core\Core\Bootstrap::class,
34 array('dummy'),
35 array(),
36 '',
37 false
38 );
39 $mockCache = $this->getMock(
40 \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class,
41 array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
42 array(),
43 '',
44 false
45 );
46 $mockCacheManager = $this->getMock(
47 \TYPO3\CMS\Core\Cache\CacheManager::class,
48 array('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
65 /**
66 * @test
67 */
68 public function loadCachedTcaSetsCacheEntryIfNoCacheEntryExists()
69 {
70 /** @var $bootstrapInstance \TYPO3\CMS\Core\Core\Bootstrap|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
71 $bootstrapInstance = $this->getAccessibleMock(
72 \TYPO3\CMS\Core\Core\Bootstrap::class,
73 array('loadExtensionTables'),
74 array(),
75 '',
76 false
77 );
78 $mockCache = $this->getMock(
79 \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class,
80 array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
81 array(),
82 '',
83 false
84 );
85 $mockCacheManager = $this->getMock(
86 \TYPO3\CMS\Core\Cache\CacheManager::class,
87 array('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 }