[TASK] Re-work/simplify copyright header in PHP files - Part 4
[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 * @author Christian Kuhn <lolli@schwarzbu.ch>
21 */
22 class BootstrapTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
23
24 /////////////////////////////////////////
25 // Tests concerning loadCachedTCA
26 /////////////////////////////////////////
27
28 /**
29 * @test
30 */
31 public function loadCachedTcaRequiresCacheFileIfCacheEntryExists() {
32 /** @var $bootstrapInstance \TYPO3\CMS\Core\Core\Bootstrap|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
33 $bootstrapInstance = $this->getAccessibleMock(
34 'TYPO3\\CMS\\Core\\Core\\Bootstrap',
35 array('dummy'),
36 array(),
37 '',
38 FALSE
39 );
40 $mockCache = $this->getMock(
41 'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
42 array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
43 array(),
44 '',
45 FALSE
46 );
47 $mockCacheManager = $this->getMock(
48 'TYPO3\\CMS\\Core\\Cache\\CacheManager',
49 array('getCache')
50 );
51 $mockCacheManager
52 ->expects($this->any())
53 ->method('getCache')
54 ->will($this->returnValue($mockCache));
55 $mockCache
56 ->expects($this->any())
57 ->method('has')
58 ->will($this->returnValue(TRUE));
59 $mockCache
60 ->expects($this->once())
61 ->method('get');
62 $bootstrapInstance->setEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', $mockCacheManager);
63 $bootstrapInstance->loadCachedTca();
64 }
65
66 /**
67 * @test
68 */
69 public function loadCachedTcaSetsCacheEntryIfNoCacheEntryExists() {
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',
73 array('loadExtensionTables'),
74 array(),
75 '',
76 FALSE
77 );
78 $mockCache = $this->getMock(
79 'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
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',
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', $mockCacheManager);
101 $bootstrapInstance->loadCachedTca();
102 }
103 }