2 declare(strict_types = 1);
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
53 protected function setUp()
55 $this->extensionKey =
'dummy';
56 $this->extensionData = [
60 $this->installMock = $this->getAccessibleMock(
61 InstallUtility::class,
67 'importStaticSqlFile',
70 'processCachingFrameworkUpdates',
71 'saveDefaultConfiguration',
73 'enrichExtensionWithDetails',
74 'ensureConfiguredDirectoriesExist',
76 'emitAfterExtensionInstallSignal',
82 $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)->getMock();
83 $this->installMock->_set(
'dependencyUtility', $dependencyUtility);
84 $this->installMock->expects($this->any())
85 ->method(
'getExtensionArray')
86 ->with($this->extensionKey)
87 ->will($this->returnCallback([$this,
'getExtensionData']));
88 $this->installMock->expects($this->any())
89 ->method(
'enrichExtensionWithDetails')
90 ->with($this->extensionKey)
91 ->will($this->returnCallback([$this,
'getExtensionData']));
106 foreach ($this->fakedExtensions as $fakeExtkey => $fakeExtension) {
120 $extKey = strtolower($this->getUniqueId(
'testing'));
122 $relPath =
'typo3temp/var/tests/' . $extKey .
'/';
123 GeneralUtility::mkdir($absExtPath);
124 $this->fakedExtensions[$extKey] = [
125 'siteRelPath' => $relPath
135 $this->installMock->expects($this->once())
136 ->method(
'updateDatabase')
137 ->with([$this->extensionKey]);
139 $cacheManagerMock = $this->getMockBuilder(CacheManager::class)->getMock();
140 $cacheManagerMock->expects($this->once())->method(
'flushCachesInGroup');
141 $this->installMock->_set(
'cacheManager', $cacheManagerMock);
142 $this->installMock->install($this->extensionKey);
150 $cacheManagerMock = $this->getMockBuilder(CacheManager::class)->getMock();
151 $cacheManagerMock->expects($this->once())->method(
'flushCachesInGroup');
152 $this->installMock->_set(
'cacheManager', $cacheManagerMock);
153 $this->installMock->expects($this->once())->method(
'loadExtension');
154 $this->installMock->install($this->extensionKey);
162 $this->extensionData[
'clearcacheonload'] =
true;
163 $cacheManagerMock = $this->getMockBuilder(CacheManager::class)->getMock();
164 $cacheManagerMock->expects($this->once())->method(
'flushCaches');
165 $this->installMock->_set(
'cacheManager', $cacheManagerMock);
166 $this->installMock->install($this->extensionKey);
174 $this->extensionData[
'clearCacheOnLoad'] =
true;
175 $cacheManagerMock = $this->getMockBuilder(CacheManager::class)->getMock();
176 $cacheManagerMock->expects($this->once())->method(
'flushCaches');
177 $this->installMock->_set(
'cacheManager', $cacheManagerMock);
178 $this->installMock->install($this->extensionKey);
186 $cacheManagerMock = $this->getMockBuilder(CacheManager::class)->getMock();
187 $cacheManagerMock->expects($this->once())->method(
'flushCachesInGroup');
188 $this->installMock->_set(
'cacheManager', $cacheManagerMock);
189 $this->installMock->expects($this->once())->method(
'ensureConfiguredDirectoriesExist');
190 $this->installMock->install($this->extensionKey);
198 $cacheManagerMock = $this->getMockBuilder(CacheManager::class)->getMock();
199 $cacheManagerMock->expects($this->once())->method(
'flushCachesInGroup');
200 $this->installMock->_set(
'cacheManager', $cacheManagerMock);
201 $this->installMock->expects($this->once())->method(
'reloadCaches');
202 $this->installMock->install($this->extensionKey);
210 $cacheManagerMock = $this->getMockBuilder(CacheManager::class)->getMock();
211 $cacheManagerMock->expects($this->once())->method(
'flushCachesInGroup');
212 $this->installMock->_set(
'cacheManager', $cacheManagerMock);
213 $this->installMock->expects($this->once())->method(
'saveDefaultConfiguration')->with($this->extensionKey);
214 $this->installMock->install($this->extensionKey);
222 $this->installMock->expects($this->once())->method(
'unloadExtension');
223 $this->installMock->uninstall($this->extensionKey);
232 'Import T3D file when T3D was imported before extension to XML' => [
237 'Import T3D file when a file was imported after extension to XML' => [
242 'Import XML file when T3D was imported before extension to XML' => [
247 'Import XML file when a file was imported after extension to XML' => [
266 GeneralUtility::mkdir($absPath .
'Initialisation');
267 file_put_contents($absPath .
'Initialisation/' . $fileName,
'DUMMY');
268 $registryMock = $this->getMockBuilder(Registry::class)
269 ->setMethods([
'get',
'set'])
272 ->expects($this->any())
274 ->will($this->returnValueMap(
276 [
'extensionDataImport', $this->fakedExtensions[$extKey][
'siteRelPath'] .
'Initialisation/' . $registryNameReturnsFalse,
null,
false],
277 [
'extensionDataImport', $this->fakedExtensions[$extKey][
'siteRelPath'] .
'Initialisation/' . $registryNameReturnsTrue,
null,
true],
281 InstallUtility::class,
282 [
'getRegistry',
'getImportExportUtility'],
287 $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)->getMock();
288 $installMock->_set(
'dependencyUtility', $dependencyUtility);
290 $installMock->expects($this->never())->method(
'getImportExportUtility');
291 $installMock->_call(
'importT3DFile', $this->fakedExtensions[$extKey][
'siteRelPath']);