/** * @test */ public function extensionStaticsAreProcessedIfExplicitlyRequested() { $identifier = $this->getUniqueId('test'); $GLOBALS['TYPO3_LOADED_EXT'] = array($identifier => array('ext_typoscript_setup.txt' => ExtensionManagementUtility::extPath('core', 'Tests/Unit/TypoScript/Fixtures/ext_typoscript_setup.txt'), 'ext_typoscript_constants.txt' => '')); $mockPackage = $this->getMock(\TYPO3\CMS\Core\Package\Package::class, array('getPackagePath'), array(), '', false); $mockPackage->expects($this->any())->method('getPackagePath')->will($this->returnValue('')); $mockPackageManager = $this->getMock(\TYPO3\CMS\Core\Package\PackageManager::class, array('isPackageActive', 'getPackage')); $mockPackageManager->expects($this->any())->method('isPackageActive')->will($this->returnValue(true)); $mockPackageManager->expects($this->any())->method('getPackage')->will($this->returnValue($mockPackage)); ExtensionManagementUtility::setPackageManager($mockPackageManager); $this->templateService->setProcessExtensionStatics(true); $this->templateService->runThroughTemplates(array(), 0); $this->assertTrue(in_array('test.Core.TypoScript = 1', $this->templateService->config)); ExtensionManagementUtility::setPackageManager(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Package\PackageManager::class)); }
/** * @test * @dataProvider configureBackendLoginSecurityLocalconfiguration * @param string $current * @param string $setting * @param bool $isPackageActive * @param bool $hasLocalConfig */ public function configureBackendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig) { /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */ $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(SilentConfigurationUpgradeService::class, array('dummy'), array(), '', false); /** @var $packageManager PackageManager|\PHPUnit_Framework_MockObject_MockObject */ $packageManager = $this->getMock(PackageManager::class, array(), array(), '', false); $packageManager->expects($this->any())->method('isPackageActive')->will($this->returnValue($isPackageActive)); ExtensionManagementUtility::setPackageManager($packageManager); $currentLocalConfiguration = array(array('BE/loginSecurityLevel', $current)); $closure = function () { throw new \RuntimeException('Path does not exist in array', 1341397869); }; $this->createConfigurationManagerWithMockedMethods(array('getLocalConfigurationValueByPath', 'setLocalConfigurationValueByPath')); if ($hasLocalConfig) { $this->configurationManager->expects($this->once())->method('getLocalConfigurationValueByPath')->will($this->returnValueMap($currentLocalConfiguration)); } else { $this->configurationManager->expects($this->once())->method('getLocalConfigurationValueByPath')->will($this->returnCallback($closure)); } $this->configurationManager->expects($this->once())->method('setLocalConfigurationValueByPath')->with($this->equalTo('BE/loginSecurityLevel'), $this->equalTo($setting)); $this->setExpectedException(RedirectException::class); $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager); $silentConfigurationUpgradeServiceInstance->_call('configureBackendLoginSecurity'); }
/** * Initializes the package system and loads the package configuration and settings * provided by the packages. * * @param string $packageManagerClassName Define an alternative package manager implementation (usually for the installer) * @return Bootstrap * @internal This is not a public API method, do not use in own extensions */ public function initializePackageManagement($packageManagerClassName) { /** @var \TYPO3\CMS\Core\Package\PackageManager $packageManager */ $packageManager = new $packageManagerClassName(); $this->setEarlyInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager); ExtensionManagementUtility::setPackageManager($packageManager); $packageManager->injectCoreCache($this->getEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('cache_core')); $dependencyResolver = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Package\DependencyResolver::class); $dependencyResolver->injectDependencyOrderingService(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Service\DependencyOrderingService::class)); $packageManager->injectDependencyResolver($dependencyResolver); $packageManager->initialize(); GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager); return $this; }
/** * @test */ public function unloadExtensionCallsPackageManagerToDeactivatePackage() { $packageName = $this->getUniqueId('foo'); /** @var PackageManager|\PHPUnit_Framework_MockObject_MockObject $packageManager */ $packageManager = $this->getMock(PackageManager::class, array('isPackageActive', 'deactivatePackage')); $packageManager->expects($this->any())->method('isPackageActive')->will($this->returnValue(TRUE)); $packageManager->expects($this->once())->method('deactivatePackage')->with($packageName); ExtensionManagementUtility::setPackageManager($packageManager); ExtensionManagementUtility::unloadExtension($packageName); }
/** * @test */ public function tryToLoadExtLocalconfAndExtTablesOfExtensionsCallsWriteCurrentExtensionToFile() { // tryToLoadExtLocalconfAndExtTablesOfExtensions() triggers a call to ExtensionManagementUtility::loadBaseTca // that works on our UnitTestPackageManager to do things. This package manager needs to be mocked here to // not trigger unwanted side effects. $packageManager = $this->getMock(\TYPO3\CMS\Core\Package\PackageManager::class, array(), array(), '', false); $packageManager->expects($this->any())->method('getActivePackages')->will($this->returnValue(array())); ExtensionManagementUtility::setPackageManager($packageManager); $extension = array('demo1' => array('type' => 'L', 'ext_tables.php' => PATH_typo3 . 'sysext/install/Tests/Unit/Controller/Action/Ajax/Fixtures/demo1/ext_tables.php')); $extensionCompatibilityTesterMock = $this->getAccessibleMock(\TYPO3\CMS\Install\Controller\Action\Ajax\ExtensionCompatibilityTester::class, array('loadExtLocalconfForExtension', 'writeCurrentExtensionToFile', 'loadExtTablesForExtension', 'removeCurrentExtensionFromFile'), array()); $extensionCompatibilityTesterMock->expects($this->atLeastOnce())->method('writeCurrentExtensionToFile')->with('demo1'); $extensionCompatibilityTesterMock->_call('tryToLoadExtLocalconfAndExtTablesOfExtensions', $extension); }
/** * @test */ public function unloadExtensionCallsPackageManagerToDeactivatePackage() { $packageName = $this->getUniqueId('foo'); $packageManager = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager', array('isPackageActive', 'deactivatePackage')); $packageManager->expects($this->any())->method('isPackageActive')->will($this->returnValue(TRUE)); $packageManager->expects($this->once())->method('deactivatePackage')->with($packageName); ExtensionManagementUtility::setPackageManager($packageManager); ExtensionManagementUtility::unloadExtension($packageName); }
/** * Initializes the package system and loads the package configuration and settings * provided by the packages. * * @param string $packageManagerClassName Define an alternative package manager implementation (usually for the installer) * @return void */ public function initializePackageManagement($packageManagerClassName = 'Helhum\\Typo3Console\\Package\\UncachedPackageManager') { require __DIR__ . '/../Package/UncachedPackageManager.php'; $packageManager = new \Helhum\Typo3Console\Package\UncachedPackageManager(); $this->setEarlyInstance($this->packageManagerInstanceName, $packageManager); Utility\ExtensionManagementUtility::setPackageManager($packageManager); // @deprecated in 6.2, will be removed in 7.0 if (is_callable(array($packageManager, 'injectClassLoader'))) { $packageManager->injectClassLoader($this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader')); } $dependencyResolver = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Package\\DependencyResolver'); // required since 7.4 if (is_callable(array($dependencyResolver, 'injectDependencyOrderingService'))) { $dependencyResolver->injectDependencyOrderingService(Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Service\\DependencyOrderingService')); } $packageManager->injectDependencyResolver($dependencyResolver); $packageManager->initialize($this); Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Package\\PackageManager', $packageManager); }
public function tearDown() { ExtensionManagementUtility::setPackageManager(new PackageManager()); }
/** * Initializes the package system and loads the package configuration and settings * provided by the packages. * * @param string $packageManagerClassName Define an alternative package manager implementation (usually for the installer) * @return Bootstrap * @internal This is not a public API method, do not use in own extensions */ public function initializePackageManagement($packageManagerClassName) { /** @var \TYPO3\CMS\Core\Package\PackageManager $packageManager */ $packageManager = new $packageManagerClassName(); $this->setEarlyInstance('TYPO3\\Flow\\Package\\PackageManager', $packageManager); Utility\ExtensionManagementUtility::setPackageManager($packageManager); $packageManager->injectClassLoader($this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader')); $packageManager->injectCoreCache($this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_core')); $packageManager->injectDependencyResolver(Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Package\\DependencyResolver')); $packageManager->initialize($this); Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Package\\PackageManager', $packageManager); return $this; }
/** * Initializes the package system and loads the package configuration and settings * provided by the packages. * * @param string $packageManagerClassName Define an alternative package manager implementation (usually for the installer) * @return void */ public function initializePackageManagement($packageManagerClassName = 'Helhum\\Typo3Console\\Package\\UncachedPackageManager') { require __DIR__ . '/../Package/UncachedPackageManager.php'; $packageManager = new \Helhum\Typo3Console\Package\UncachedPackageManager(); $this->setEarlyInstance('TYPO3\\Flow\\Package\\PackageManager', $packageManager); Utility\ExtensionManagementUtility::setPackageManager($packageManager); $packageManager->injectClassLoader($this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader')); $packageManager->injectDependencyResolver(Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Package\\DependencyResolver')); $packageManager->initialize($this); Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Package\\PackageManager', $packageManager); }