当前位置: 首页>>代码示例>>PHP>>正文


PHP GeneralUtility::setSingletonInstance方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::setSingletonInstance方法的具体用法?PHP GeneralUtility::setSingletonInstance怎么用?PHP GeneralUtility::setSingletonInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Utility\GeneralUtility的用法示例。


在下文中一共展示了GeneralUtility::setSingletonInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * 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);
 }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:10,代码来源:FileExtensionFilterTest.php

示例2: setUpTYPO3Globals

 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);
 }
开发者ID:r3h6,项目名称:TYPO3.EXT.error404page,代码行数:9,代码来源:UnitTestCase.php

示例3: setUp

 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;
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:9,代码来源:ResourceStorageTest.php

示例4: setUpBasicFrontendEnvironment

 /**
  * 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;
 }
开发者ID:r3h6,项目名称:TYPO3.EXT.error404page,代码行数:13,代码来源:FunctionalTestCase.php

示例5: executeCallsUpdateExtListOfRepositoryHelper

 /**
  * @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();
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:13,代码来源:UpdateExtensionListTaskTest.php

示例6: getFolderCorrectlySetsFolderName

 /**
  * @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);
 }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:13,代码来源:AbstractDriverTest.php

示例7: setUp

 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;
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:11,代码来源:ResourceStorageTest.php

示例8: setUp

 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();
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:11,代码来源:TcaFlexFetchTest.php

示例9: setUp

 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);
 }
开发者ID:visol,项目名称:ext-tika,代码行数:11,代码来源:ServiceUnitTestCase.php

示例10: executeCallsPersistAllOnPersistenceManager

 /**
  * @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();
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:14,代码来源:UpdateExtensionListTaskTest.php

示例11: setUp

 /**
  * 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());
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:15,代码来源:PostProcessorTest.php

示例12: setUp

 /**
  *
  */
 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);
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:15,代码来源:AttributesAttributeTest.php

示例13: getDriverObjectAcceptsDriverClassName

 /**
  * @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);
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:15,代码来源:ResourceFactoryTest.php

示例14: initializeCachingFramework

 /**
  * 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;
     }
 }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:19,代码来源:Cache.php

示例15: executeDoesNotCallCollectGarbageOfNotConfiguredBackend

 /**
  * @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();
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:17,代码来源:CachingFrameworkGarbageCollectionTest.php


注:本文中的TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。