[TASK] Doctrine: Migrate DatabaseWriter
[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->getMockBuilder(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class)
40 ->setMethods(array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'))
41 ->disableOriginalConstructor()
42 ->getMock();
43
44 $mockCacheManager = $this->getMockBuilder(\TYPO3\CMS\Core\Cache\CacheManager::class)
45 ->setMethods(array('getCache'))
46 ->getMock();
47 $mockCacheManager
48 ->expects($this->any())
49 ->method('getCache')
50 ->will($this->returnValue($mockCache));
51 $mockCache
52 ->expects($this->any())
53 ->method('has')
54 ->will($this->returnValue(true));
55 $mockCache
56 ->expects($this->once())
57 ->method('get');
58 $bootstrapInstance->setEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $mockCacheManager);
59 $bootstrapInstance->loadCachedTca();
60 }
61
62 /**
63 * @test
64 */
65 public function loadCachedTcaSetsCacheEntryIfNoCacheEntryExists()
66 {
67 /** @var $bootstrapInstance \TYPO3\CMS\Core\Core\Bootstrap|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
68 $bootstrapInstance = $this->getAccessibleMock(
69 \TYPO3\CMS\Core\Core\Bootstrap::class,
70 array('loadExtensionTables'),
71 array(),
72 '',
73 false
74 );
75 $mockCache = $this->getMockBuilder(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class)
76 ->setMethods(array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'))
77 ->disableOriginalConstructor()
78 ->getMock();
79
80 $mockCacheManager = $this->getMockBuilder(\TYPO3\CMS\Core\Cache\CacheManager::class)
81 ->setMethods(array('getCache'))
82 ->getMock();
83 $mockCacheManager
84 ->expects($this->any())
85 ->method('getCache')
86 ->will($this->returnValue($mockCache));
87 $mockCache
88 ->expects($this->any())
89 ->method('has')
90 ->will($this->returnValue(false));
91 $mockCache
92 ->expects($this->once())
93 ->method('set');
94 $bootstrapInstance->setEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $mockCacheManager);
95 $bootstrapInstance->loadCachedTca();
96 }
97 }