dc226f453ee078e979c529469b7d1adf2c853e23
[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 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Testcase
29 *
30 * @author Christian Kuhn <lolli@schwarzbu.ch>
31 */
32 class BootstrapTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
33
34 /////////////////////////////////////////
35 // Tests concerning loadCachedTCA
36 /////////////////////////////////////////
37
38 /**
39 * @test
40 */
41 public function loadCachedTcaRequiresCacheFileIfCacheEntryExists() {
42 /** @var $bootstrapInstance \TYPO3\CMS\Core\Core\Bootstrap|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
43 $bootstrapInstance = $this->getAccessibleMock(
44 'TYPO3\\CMS\\Core\\Core\\Bootstrap',
45 array('dummy'),
46 array(),
47 '',
48 FALSE
49 );
50 $mockCache = $this->getMock(
51 'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
52 array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
53 array(),
54 '',
55 FALSE
56 );
57 $GLOBALS['typo3CacheManager'] = $this->getMock(
58 'TYPO3\\CMS\\Core\\Cache\\CacheManager',
59 array('getCache')
60 );
61 $GLOBALS['typo3CacheManager']
62 ->expects($this->any())
63 ->method('getCache')
64 ->will($this->returnValue($mockCache));
65 $mockCache
66 ->expects($this->any())
67 ->method('has')
68 ->will($this->returnValue(TRUE));
69 $mockCache
70 ->expects($this->once())
71 ->method('requireOnce');
72 $bootstrapInstance->loadCachedTca();
73 }
74
75 /**
76 * @test
77 */
78 public function loadCachedTcaSetsCacheEntryIfNoCacheEntryExists() {
79 /** @var $bootstrapInstance \TYPO3\CMS\Core\Core\Bootstrap|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
80 $bootstrapInstance = $this->getAccessibleMock(
81 'TYPO3\\CMS\\Core\\Core\\Bootstrap',
82 array('loadExtensionTables'),
83 array(),
84 '',
85 FALSE
86 );
87 $mockCache = $this->getMock(
88 'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
89 array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
90 array(),
91 '',
92 FALSE
93 );
94 $GLOBALS['typo3CacheManager'] = $this->getMock(
95 'TYPO3\\CMS\\Core\\Cache\\CacheManager',
96 array('getCache')
97 );
98 $GLOBALS['typo3CacheManager']
99 ->expects($this->any())
100 ->method('getCache')
101 ->will($this->returnValue($mockCache));
102 $mockCache
103 ->expects($this->any())
104 ->method('has')
105 ->will($this->returnValue(FALSE));
106 $mockCache
107 ->expects($this->once())
108 ->method('set');
109 $bootstrapInstance->loadCachedTca();
110 }
111 }