/**
  * Sets up this test suite.
  */
 protected function setUp()
 {
     $this->filter = new \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter();
     $this->tceMainMock = $this->getMock('TYPO3\\CMS\\Core\\DataHandler\\DataHandler', array('deleteAction'), array());
     $this->fileFactoryMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', array('getFileReferenceObject'), array());
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', $this->fileFactoryMock);
 }
Ejemplo n.º 2
0
 public function setUpTYPO3Globals()
 {
     $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', get_class_methods('TYPO3\\CMS\\Core\\Database\\DatabaseConnection'), array(), '', false);
     $configurationManager = $this->getMock('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager', get_class_methods('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'), array(), '', false);
     GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager', $configurationManager);
     $GLOBALS['TSFE'] = new \stdClass();
     $GLOBALS['TSFE']->sys_language_uid = 0;
     $GLOBALS['TSFE']->csConvObj = $this->getMock('TYPO3\\CMS\\Core\\Charset\\CharsetConverter', get_class_methods('TYPO3\\CMS\\Core\\Charset\\CharsetConverter'), array(), '', false);
 }
Ejemplo n.º 3
0
 public function setUp()
 {
     parent::setUp();
     $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository'));
     $databaseMock = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
     $databaseMock->expects($this->any())->method('exec_SELECTgetRows')->with('*', 'sys_file_storage', '1=1', '', 'name', '', 'uid')->willReturn(array());
     $GLOBALS['TYPO3_DB'] = $databaseMock;
 }
 /**
  * Minimal frontent environment to satisfy Extbase Typo3DbBackend.
  */
 protected function setUpBasicFrontendEnvironment()
 {
     $environmentServiceMock = $this->getMock('TYPO3\\CMS\\Extbase\\Service\\EnvironmentService');
     $environmentServiceMock->expects($this->any())->method('isEnvironmentInFrontendMode')->willReturn(true);
     GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Service\\EnvironmentService', $environmentServiceMock);
     $pageRepositoryFixture = new PageRepository();
     $frontendControllerMock = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array(), '', false);
     $frontendControllerMock->sys_page = $pageRepositoryFixture;
     $GLOBALS['TSFE'] = $frontendControllerMock;
 }
 /**
  * @test
  */
 public function executeCallsUpdateExtListOfRepositoryHelper()
 {
     $repositoryHelperMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper');
     $repositoryHelperMock->expects($this->once())->method('updateExtList');
     $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $objectManagerMock->expects($this->once())->method('get')->with('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper')->will($this->returnValue($repositoryHelperMock));
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', $objectManagerMock);
     $task = new \TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask();
     $task->execute();
 }
Ejemplo n.º 6
0
 /**
  * @test
  */
 public function getFolderCorrectlySetsFolderName()
 {
     $identifier = '/someFolder/someSubfolder/';
     $fixture = $this->createDriverFixture(array());
     $fixture->setStorage($this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE));
     $mockedFactory = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
     $mockedFactory->expects($this->once())->method('createFolderObject')->with($this->anything(), $this->anything(), 'someSubfolder');
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', $mockedFactory);
     $fixture->getFolder($identifier);
 }
Ejemplo n.º 7
0
 protected function setUp()
 {
     parent::setUp();
     $this->singletonInstances = GeneralUtility::getSingletonInstances();
     /** @var FileRepository|\PHPUnit_Framework_MockObject_MockObject $fileRepositoryMock */
     $fileRepositoryMock = $this->getMock(FileRepository::class);
     GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryMock);
     $databaseMock = $this->getMock(DatabaseConnection::class);
     $databaseMock->expects($this->any())->method('exec_SELECTgetRows')->with('*', 'sys_file_storage', '1=1', '', 'name', '', 'uid')->willReturn(array());
     $GLOBALS['TYPO3_DB'] = $databaseMock;
 }
Ejemplo n.º 8
0
 protected function setUp()
 {
     $this->singletonInstances = GeneralUtility::getSingletonInstances();
     // Suppress cache foo in xml helpers of GeneralUtility
     /** @var CacheManager|ObjectProphecy $cacheManagerProphecy */
     $cacheManagerProphecy = $this->prophesize(CacheManager::class);
     GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
     $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
     $cacheManagerProphecy->getCache(Argument::cetera())->willReturn($cacheFrontendProphecy->reveal());
     $this->subject = new TcaFlexFetch();
 }
Ejemplo n.º 9
0
 protected function setUp()
 {
     $this->singletonInstances = GeneralUtility::getSingletonInstances();
     // Disable xml2array cache used by ResourceFactory
     GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->setCacheConfigurations(array('cache_hash' => array('frontend' => 'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend', 'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\TransientMemoryBackend')));
     $this->setUpDocumentsStorageMock();
     $this->setUpLanguagesStorageMock();
     $mockedMetaDataRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Index\\MetaDataRepository');
     $mockedMetaDataRepository->expects($this->any())->method('findByFile')->will($this->returnValue(array('file' => 1)));
     GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\Index\\MetaDataRepository', $mockedMetaDataRepository);
 }
 /**
  * @test
  */
 public function executeCallsPersistAllOnPersistenceManager()
 {
     $objectManagerMock = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
     $objectManagerMock->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper::class)->will($this->returnValue($this->repositoryHelper));
     $persistenceManagerMock = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class);
     $persistenceManagerMock->expects($this->once())->method('persistAll');
     $objectManagerMock->expects($this->at(1))->method('get')->will($this->returnValue($persistenceManagerMock));
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class, $objectManagerMock);
     $task = $this->getMock(\TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask::class, array('dummy'), array(), '', FALSE);
     $task->execute();
 }
Ejemplo n.º 11
0
 /**
  * Set up
  */
 protected function setUp()
 {
     $this->singletonInstances = GeneralUtility::getSingletonInstances();
     $this->formProphecy = $this->prophesize('TYPO3\\CMS\\Form\\Domain\\Model\\Form');
     $this->typoScriptFactoryProphecy = $this->prophesize('TYPO3\\CMS\\Form\\Domain\\Factory\\TypoScriptFactory');
     $this->typoScriptFactoryProphecy->getLayoutFromTypoScript(Argument::any())->willReturn(array());
     GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Form\\Domain\\Factory\\TypoScriptFactory', $this->typoScriptFactoryProphecy->reveal());
     $this->typoScriptLayoutProphecy = $this->prophesize('TYPO3\\CMS\\Form\\Layout');
     $templateServiceProphecy = $this->prophesize('TYPO3\\CMS\\Core\\TypoScript\\TemplateService');
     $templateServiceProphecy->sortedKeyList(Argument::any())->willReturn(array(10, 20));
     GeneralUtility::addInstance('TYPO3\\CMS\\Core\\TypoScript\\TemplateService', $templateServiceProphecy->reveal());
 }
Ejemplo n.º 12
0
 /**
  *
  */
 public function setUp()
 {
     $contentObjectRendererProphecy = $this->prophesize('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     GeneralUtility::addInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', $contentObjectRendererProphecy->reveal());
     $localisationProphecy = $this->prophesize('TYPO3\\CMS\\Form\\Localization');
     GeneralUtility::addInstance('TYPO3\\CMS\\Form\\Localization', $localisationProphecy->reveal());
     $requestProphecy = $this->prophesize('TYPO3\\CMS\\Form\\Request');
     $this->singletonInstances = GeneralUtility::getSingletonInstances();
     GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Form\\Request', $requestProphecy->reveal());
     $this->elementId = uniqid('elementId_', TRUE);
     $this->subject = new AttributesAttribute($this->elementId);
 }
Ejemplo n.º 13
0
 /**
  * @test
  */
 public function getDriverObjectAcceptsDriverClassName()
 {
     $mockedDriver = $this->getMockForAbstractClass(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class);
     $driverFixtureClass = get_class($mockedDriver);
     \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance($driverFixtureClass, $mockedDriver);
     $mockedMount = $this->getMock(\TYPO3\CMS\Core\Resource\ResourceStorage::class, array(), array(), '', false);
     $mockedRegistry = $this->getMock(\TYPO3\CMS\Core\Resource\Driver\DriverRegistry::class);
     $mockedRegistry->expects($this->once())->method('getDriverClass')->with($this->equalTo($driverFixtureClass))->will($this->returnValue($driverFixtureClass));
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Resource\Driver\DriverRegistry::class, $mockedRegistry);
     $obj = $this->subject->getDriverObject($driverFixtureClass, array());
     $this->assertInstanceOf(\TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class, $obj);
 }
Ejemplo n.º 14
0
 /**
  * Initializes the caching framework by loading the cache manager and factory
  * into the global context.
  *
  * @return void
  */
 public static function initializeCachingFramework()
 {
     if (!self::isCachingFrameworkInitialized()) {
         // New operator used on purpose, makeInstance() is not ready to be used so early in bootstrap
         $GLOBALS['typo3CacheManager'] = new \TYPO3\CMS\Core\Cache\CacheManager();
         \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', $GLOBALS['typo3CacheManager']);
         $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
         // New operator used on purpose, makeInstance() is not ready to be used so early in bootstrap
         $GLOBALS['typo3CacheFactory'] = new \TYPO3\CMS\Core\Cache\CacheFactory('production', $GLOBALS['typo3CacheManager']);
         \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheFactory', $GLOBALS['typo3CacheFactory']);
         self::$isCachingFrameworkInitialized = TRUE;
     }
 }
 /**
  * @test
  */
 public function executeDoesNotCallCollectGarbageOfNotConfiguredBackend()
 {
     $cache = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\StringFrontend::class, array(), array(), '', false);
     $cache->expects($this->any())->method('getIdentifier')->will($this->returnValue('cache'));
     $cache->expects($this->never())->method('collectGarbage');
     $mockCacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
     $mockCacheManager->registerCache($cache);
     GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $mockCacheManager);
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = array('cache' => array('frontend' => \TYPO3\CMS\Core\Cache\Frontend\StringFrontend::class, 'backend' => \TYPO3\CMS\Core\Cache\Backend\AbstractBackend::class));
     /** @var \TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask|\PHPUnit_Framework_MockObject_MockObject $subject */
     $subject = $this->getMock(\TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask::class, array('dummy'), array(), '', false);
     $subject->selectedBackends = array(\TYPO3\CMS\Core\Cache\Backend\NullBackend::class);
     $subject->execute();
 }
Ejemplo n.º 16
0
 /**
  * Initializes the caching framework by loading the cache manager and factory
  * into the global context.
  *
  * @return CacheManager
  */
 public static function initializeCachingFramework()
 {
     if (!self::isCachingFrameworkInitialized()) {
         // New operator used on purpose, makeInstance() is not ready to be used so early in bootstrap
         self::$cacheManager = new CacheManager();
         GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, self::$cacheManager);
         self::$cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
         // New operator used on purpose, makeInstance() is not ready to be used so early in bootstrap
         self::$cacheFactory = new CacheFactory('production', self::$cacheManager);
         GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheFactory::class, self::$cacheFactory);
         self::$isCachingFrameworkInitialized = TRUE;
     }
     return self::$cacheManager;
 }
Ejemplo n.º 17
0
 /**
  * @test
  */
 public function addDataSetsFolderData()
 {
     $input = ['databaseRow' => ['aField' => '1:/aFolder/anotherFolder/'], 'processedTca' => ['columns' => ['aField' => ['config' => ['type' => 'group', 'internal_type' => 'folder']]]]];
     /** @var Folder|ObjectProphecy $relationHandlerProphecy */
     $folderProphecy = $this->prophesize(Folder::class);
     $folderProphecy->getIdentifier()->shouldBeCalled()->willReturn('anotherFolder');
     /** @var ResourceFactory|ObjectProphecy $relationHandlerProphecy */
     $resourceFactoryProphecy = $this->prophesize(ResourceFactory::class);
     GeneralUtility::setSingletonInstance(ResourceFactory::class, $resourceFactoryProphecy->reveal());
     $resourceFactoryProphecy->retrieveFileOrFolderObject('1:/aFolder/anotherFolder/')->shouldBeCalled()->willReturn($folderProphecy->reveal());
     $expected = $input;
     $expected['databaseRow']['aField'] = '1%3A%2FaFolder%2FanotherFolder%2F|anotherFolder';
     $this->assertSame($expected, $this->subject->addData($input));
 }
Ejemplo n.º 18
0
 public function setUp()
 {
     $this->singletonInstances = GeneralUtility::getSingletonInstances();
     // Disable xml2array cache used by ResourceFactory
     GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->setCacheConfigurations(array('cache_hash' => array('frontend' => 'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend', 'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\TransientMemoryBackend')));
     $this->testDocumentsPath = ExtensionManagementUtility::extPath('tika') . 'Tests/TestDocuments/';
     $driver = $this->createDriverFixture(array('basePath' => $this->testDocumentsPath, 'caseSensitive' => TRUE));
     $storageRecord = array('uid' => $this->storageUid, 'is_public' => TRUE, 'is_writable' => FALSE, 'is_browsable' => TRUE, 'is_online' => TRUE, 'configuration' => $this->convertConfigurationArrayToFlexformXml(array('basePath' => $this->testDocumentsPath, 'pathType' => 'absolute', 'caseSensitive' => '1')));
     $this->storageMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', NULL, array($driver, $storageRecord));
     $this->storageMock->expects($this->any())->method('getUid')->will($this->returnValue($this->storageUid));
     $mockedMetaDataRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Index\\MetaDataRepository');
     $mockedMetaDataRepository->expects($this->any())->method('findByFile')->will($this->returnValue(array('file' => 1)));
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\Index\\MetaDataRepository', $mockedMetaDataRepository);
 }
Ejemplo n.º 19
0
 /**
  * @test
  */
 public function configureObjectManagerRespectsOverridingOfAlternativeObjectRegistrationViaPluginConfiguration()
 {
     /** @var $objectContainer \TYPO3\CMS\Extbase\Object\Container\Container|\PHPUnit_Framework_MockObject_MockObject */
     $objectContainer = $this->getMock(\TYPO3\CMS\Extbase\Object\Container\Container::class, array('registerImplementation'));
     $objectContainer->expects($this->once())->method('registerImplementation')->with(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class, 'TYPO3\\CMS\\Extbase\\Persistence\\Reddis\\PersistenceManager');
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class, $objectContainer);
     $frameworkSettings['objects'] = array('TYPO3\\CMS\\Extbase\\Persistence\\PersistenceManagerInterface.' => array('className' => 'TYPO3\\CMS\\Extbase\\Persistence\\Reddis\\PersistenceManager'));
     /** @var $configurationManagerMock \TYPO3\CMS\Extbase\Configuration\ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\Tx_Phpunit_Interface_AccessibleObject */
     $configurationManagerMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class, array('getConfiguration'));
     $configurationManagerMock->expects($this->any())->method('getConfiguration')->with('Framework')->will($this->returnValue($frameworkSettings));
     /** @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject  $objectManager */
     $objectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
     /** @var $bootstrapMock \TYPO3\CMS\Extbase\Core\Bootstrap|\PHPUnit_Framework_MockObject_MockObject|\Tx_Phpunit_Interface_AccessibleObject */
     $bootstrapMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Core\Bootstrap::class, array('inject'));
     $bootstrapMock->_set('objectManager', $objectManager);
     $bootstrapMock->_set('configurationManager', $configurationManagerMock);
     $bootstrapMock->configureObjectManager();
 }
 /**
  * @test
  */
 public function renderAssignsSettingsArrayToView()
 {
     $this->addMockViewToSubject();
     $configuration = array('settings.' => array('foo' => 'value', 'bar.' => array('baz' => 'value2')));
     $expectedSettingsToBeSet = array('foo' => 'value', 'bar' => array('baz' => 'value2'));
     /** @var TypoScriptService|\PHPUnit_Framework_MockObject_MockObject $typoScriptServiceMock */
     $typoScriptServiceMock = $this->getMock(\TYPO3\CMS\Extbase\Service\TypoScriptService::class);
     $typoScriptServiceMock->expects($this->once())->method('convertTypoScriptArrayToPlainArray')->with($configuration['settings.'])->will($this->returnValue($expectedSettingsToBeSet));
     GeneralUtility::setSingletonInstance(\TYPO3\CMS\Extbase\Service\TypoScriptService::class, $typoScriptServiceMock);
     $this->standaloneView->expects($this->at(1))->method('assign')->with('settings', $expectedSettingsToBeSet);
     $this->subject->render($configuration);
 }
Ejemplo n.º 21
0
 /**
  * @test
  */
 public function addDataItemsProcFuncEnqueuesFlashMessageOnException()
 {
     $input = ['tableName' => 'aTable', 'databaseRow' => ['aField' => 'aValue'], 'pageTsConfig' => ['TCEFORM.' => ['aTable.' => ['aField.' => ['itemsProcFunc.' => ['itemParamKey' => 'itemParamValue']]]]], 'processedTca' => ['columns' => ['aField' => ['config' => ['type' => 'check', 'aKey' => 'aValue', 'items' => [0 => ['foo', 'bar']], 'itemsProcFunc' => function (array $parameters, $pObj) {
         throw new \UnexpectedValueException('anException', 1438604329);
     }]]]]];
     $languageService = $this->prophesize(LanguageService::class);
     $GLOBALS['LANG'] = $languageService->reveal();
     /** @var FlashMessage|ObjectProphecy $flashMessage */
     $flashMessage = $this->prophesize(FlashMessage::class);
     GeneralUtility::addInstance(FlashMessage::class, $flashMessage->reveal());
     /** @var FlashMessageService|ObjectProphecy $flashMessageService */
     $flashMessageService = $this->prophesize(FlashMessageService::class);
     GeneralUtility::setSingletonInstance(FlashMessageService::class, $flashMessageService->reveal());
     /** @var FlashMessageQueue|ObjectProphecy $flashMessageQueue */
     $flashMessageQueue = $this->prophesize(FlashMessageQueue::class);
     $flashMessageService->getMessageQueueByIdentifier(Argument::cetera())->willReturn($flashMessageQueue->reveal());
     $flashMessageQueue->enqueue($flashMessage)->shouldBeCalled();
     $this->subject->addData($input);
 }
Ejemplo n.º 22
0
 /**
  * Initialize caching framework, and re-initializes it (e.g. in the install tool) by recreating the instances
  * again despite the Singleton instance
  *
  * @return Bootstrap
  * @internal This is not a public API method, do not use in own extensions
  */
 public function initializeCachingFramework()
 {
     $cacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
     $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
     GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $cacheManager);
     $cacheFactory = new \TYPO3\CMS\Core\Cache\CacheFactory('production', $cacheManager);
     GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheFactory::class, $cacheFactory);
     $this->setEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $cacheManager);
     return $this;
 }
 /**
  * @test
  */
 public function doesMakeCategorizableCallsTheCategoryRegistryWithFieldName()
 {
     $extensionKey = $this->getUniqueId('extension');
     $tableName = $this->getUniqueId('table');
     $fieldName = $this->getUniqueId('field');
     /** @var CategoryRegistry|\PHPUnit_Framework_MockObject_MockObject $registryMock */
     $registryMock = $this->getMock(CategoryRegistry::class);
     $registryMock->expects($this->once())->method('add')->with($extensionKey, $tableName, $fieldName, array());
     GeneralUtility::setSingletonInstance(CategoryRegistry::class, $registryMock);
     ExtensionManagementUtility::makeCategorizable($extensionKey, $tableName, $fieldName);
 }
 /**
  * @test
  */
 public function doesMakeCategorizableCallsTheCategoryRegistryWithFieldName()
 {
     $extensionKey = $this->getUniqueId('extension');
     $tableName = $this->getUniqueId('table');
     $fieldName = $this->getUniqueId('field');
     $registryMock = $this->getMock('TYPO3\\CMS\\Core\\Category\\CategoryRegistry');
     $registryMock->expects($this->once())->method('add')->with($extensionKey, $tableName, $fieldName, array());
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Category\\CategoryRegistry', $registryMock);
     ExtensionManagementUtility::makeCategorizable($extensionKey, $tableName, $fieldName);
 }
Ejemplo n.º 25
0
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
     $this->view = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\StandaloneView', array('dummy'), array(), '', FALSE);
     $this->mockTemplateParser = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\TemplateParser');
     $this->mockParsedTemplate = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\ParsedTemplateInterface');
     $this->mockTemplateParser->expects($this->any())->method('parse')->will($this->returnValue($this->mockParsedTemplate));
     $this->mockConfigurationManager = $this->getMock('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
     $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'objectManagerCallback')));
     $this->mockRequest = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
     $this->mockUriBuilder = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
     $this->mockContentObject = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     $this->mockControllerContext = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext');
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockRequest));
     $this->mockViewHelperVariableContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
     $this->mockRenderingContext = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext');
     $this->mockRenderingContext->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->mockRenderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->mockViewHelperVariableContainer));
     $this->view->_set('templateParser', $this->mockTemplateParser);
     $this->view->_set('objectManager', $this->mockObjectManager);
     $this->view->setRenderingContext($this->mockRenderingContext);
     $this->mockTemplateCompiler = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Compiler\\TemplateCompiler');
     $this->view->_set('templateCompiler', $this->mockTemplateCompiler);
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', $this->mockObjectManager);
     \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', $this->mockContentObject);
     $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array(), array(), '', FALSE);
     $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', array(), array(), '', FALSE);
     $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', $mockCacheManager);
 }
Ejemplo n.º 26
0
 /**
  * @param ConsoleBootstrap $bootstrap
  */
 public static function initializeCachingFramework(ConsoleBootstrap $bootstrap)
 {
     // Cache framework initialisation for TYPO3 CMS <= 7.3
     if (class_exists('TYPO3\\CMS\\Core\\Cache\\Cache')) {
         $bootstrap->setEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework());
         // @deprecated since 6.2 will be removed in two versions
         if (class_exists('TYPO3\\CMS\\Core\\Compatibility\\GlobalObjectDeprecationDecorator')) {
             $GLOBALS['typo3CacheManager'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheManager');
             $GLOBALS['typo3CacheFactory'] = new \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator('TYPO3\\CMS\\Core\\Cache\\CacheFactory');
         }
     } else {
         $cacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
         $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
         \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $cacheManager);
         $cacheFactory = new \TYPO3\CMS\Core\Cache\CacheFactory('production', $cacheManager);
         \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheFactory::class, $cacheFactory);
         $bootstrap->setEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $cacheManager);
     }
 }
 /**
  * Sets up this test case
  *
  * @return void
  */
 protected function setUp()
 {
     $this->singletonInstances = GeneralUtility::getSingletonInstances();
     $this->view = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\StandaloneView::class, array('testFileExistence', 'buildParserConfiguration', 'getOrParseAndStoreTemplate'), array(), '', false);
     $this->mockConfigurationManager = $this->getMock(ConfigurationManagerInterface::class);
     $this->mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
     $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'objectManagerCallback')));
     $this->mockRequest = $this->getMock(Request::class);
     $this->mockUriBuilder = $this->getMock(UriBuilder::class);
     $this->mockContentObject = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
     $this->mockControllerContext = $this->getMock(ControllerContext::class);
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockRequest));
     $this->mockTemplatePaths = $this->getMock(TemplatePaths::class);
     $this->mockViewHelperVariableContainer = $this->getMock(ViewHelperVariableContainer::class);
     $this->mockRenderingContext = $this->getMock(\TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextFixture::class);
     $this->mockRenderingContext->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->mockRenderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->mockViewHelperVariableContainer));
     $this->mockRenderingContext->expects($this->any())->method('getVariableProvider')->willReturn($this->mockVariableProvider);
     $this->mockRenderingContext->expects($this->any())->method('getTemplatePaths')->willReturn($this->mockTemplatePaths);
     $this->view->_set('objectManager', $this->mockObjectManager);
     $this->view->_set('baseRenderingContext', $this->mockRenderingContext);
     $this->view->_set('controllerContext', $this->mockControllerContext);
     $this->view->expects($this->any())->method('getOrParseAndStoreTemplate')->willReturn($this->mockParsedTemplate);
     GeneralUtility::setSingletonInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class, $this->mockObjectManager);
     GeneralUtility::addInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, $this->mockContentObject);
     $this->mockCacheManager = $this->getMock(\TYPO3\CMS\Core\Cache\CacheManager::class, array(), array(), '', false);
     $mockCache = $this->getMock(\TYPO3Fluid\Fluid\Core\Cache\FluidCacheInterface::class, array(), array(), '', false);
     $this->mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
     GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $this->mockCacheManager);
 }
Ejemplo n.º 28
0
 /**
  * @test
  */
 public function resetSingletonInstancesResetsPreviouslySetInstance()
 {
     $instance = $this->getMock('TYPO3\\CMS\\Core\\SingletonInterface');
     $instanceClassName = get_class($instance);
     Utility\GeneralUtility::setSingletonInstance($instanceClassName, $instance);
     Utility\GeneralUtility::resetSingletonInstances(array());
     $registeredSingletonInstances = Utility\GeneralUtility::getSingletonInstances();
     $this->assertArrayNotHasKey($instanceClassName, $registeredSingletonInstances);
 }
 /**
  * Wrapper for buildBaseTcaFromSingleFiles handling caching.
  *
  * This builds 'base' TCA that is later overloaded by ext_tables.php.
  *
  * Use a cache file if exists and caching is allowed.
  *
  * This is an internal method. It is only used during bootstrap and
  * extensions should not use it!
  *
  * @param bool $allowCaching Whether or not to load / create concatenated cache file
  * @return void
  * @access private
  */
 public static function loadBaseTca($allowCaching = true)
 {
     if ($allowCaching) {
         $cacheIdentifier = static::getBaseTcaCacheIdentifier();
         /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
         $codeCache = static::getCacheManager()->getCache('cache_core');
         if ($codeCache->has($cacheIdentifier)) {
             // substr is necessary, because the php frontend wraps php code around the cache value
             $cacheData = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
             $GLOBALS['TCA'] = $cacheData['tca'];
             GeneralUtility::setSingletonInstance(CategoryRegistry::class, $cacheData['categoryRegistry']);
         } else {
             static::buildBaseTcaFromSingleFiles();
             static::createBaseTcaCacheFile();
         }
     } else {
         static::buildBaseTcaFromSingleFiles();
     }
 }
Ejemplo n.º 30
0
 /**
  * @test
  */
 public function getSubfolderCallsFactoryWithCorrectArguments()
 {
     $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
     $mockedStorage->expects($this->once())->method('hasFolderInFolder')->with($this->equalTo('someSubfolder'))->will($this->returnValue(TRUE));
     $mockedFactory = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
     $mockedFactory->expects($this->once())->method('createFolderObject')->with($mockedStorage, '/somePath/someFolder/someSubfolder/', 'someSubfolder');
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', $mockedFactory);
     $fixture = $this->createFolderFixture('/somePath/someFolder/', 'someFolder', $mockedStorage);
     $fixture->getSubfolder('someSubfolder');
 }