/**
  * Sets up this test case
  *
  */
 protected function setUp()
 {
     vfsStream::setup('Test');
     $mockBootstrap = $this->getMock('TYPO3\\Flow\\Core\\Bootstrap', array(), array(), '', FALSE);
     $mockBootstrap->expects($this->any())->method('getSignalSlotDispatcher')->will($this->returnValue($this->getMock('TYPO3\\Flow\\SignalSlot\\Dispatcher')));
     $mockObjectManager = $this->getMock('TYPO3\\Flow\\Object\\ObjectManagerInterface');
     $mockBootstrap->expects($this->any())->method('getObjectManager')->will($this->returnValue($mockObjectManager));
     $mockReflectionService = $this->getMock('TYPO3\\Flow\\Reflection\\ReflectionService');
     $mockReflectionService->expects($this->any())->method('getClassNameByObject')->will($this->returnCallback(function ($object) {
         if ($object instanceof \Doctrine\ORM\Proxy\Proxy) {
             return get_parent_class($object);
         }
         return get_class($object);
     }));
     $mockObjectManager->expects($this->any())->method('get')->with('TYPO3\\Flow\\Reflection\\ReflectionService')->will($this->returnValue($mockReflectionService));
     $this->packageManager = new \TYPO3\Flow\Package\PackageManager();
     mkdir('vfs://Test/Packages/Application', 0700, TRUE);
     mkdir('vfs://Test/Configuration');
     $mockClassLoader = $this->getMock('TYPO3\\Flow\\Core\\ClassLoader');
     $composerNameToPackageKeyMap = array('typo3/flow' => 'TYPO3.Flow');
     $this->packageManager->injectClassLoader($mockClassLoader);
     $this->inject($this->packageManager, 'composerNameToPackageKeyMap', $composerNameToPackageKeyMap);
     $this->inject($this->packageManager, 'packagesBasePath', 'vfs://Test/Packages/');
     $this->inject($this->packageManager, 'packageStatesPathAndFilename', 'vfs://Test/Configuration/PackageStates.php');
     $this->packageManager->initialize($mockBootstrap);
 }
 /**
  * Sets up this test case
  *
  */
 protected function setUp()
 {
     ComposerUtility::flushCaches();
     vfsStream::setup('Test');
     $this->mockBootstrap = $this->getMockBuilder(Bootstrap::class)->disableOriginalConstructor()->getMock();
     $this->mockBootstrap->expects($this->any())->method('getSignalSlotDispatcher')->will($this->returnValue($this->createMock(\TYPO3\Flow\SignalSlot\Dispatcher::class)));
     $this->mockApplicationContext = $this->getMockBuilder(ApplicationContext::class)->disableOriginalConstructor()->getMock();
     $this->mockBootstrap->expects($this->any())->method('getContext')->will($this->returnValue($this->mockApplicationContext));
     $mockObjectManager = $this->createMock(\TYPO3\Flow\Object\ObjectManagerInterface::class);
     $this->mockBootstrap->expects($this->any())->method('getObjectManager')->will($this->returnValue($mockObjectManager));
     $mockReflectionService = $this->createMock(\TYPO3\Flow\Reflection\ReflectionService::class);
     $mockReflectionService->expects($this->any())->method('getClassNameByObject')->will($this->returnCallback(function ($object) {
         if ($object instanceof \Doctrine\ORM\Proxy\Proxy) {
             return get_parent_class($object);
         }
         return get_class($object);
     }));
     $mockObjectManager->expects($this->any())->method('get')->with(\TYPO3\Flow\Reflection\ReflectionService::class)->will($this->returnValue($mockReflectionService));
     mkdir('vfs://Test/Packages/Application', 0700, true);
     mkdir('vfs://Test/Configuration');
     $this->packageManager = new PackageManager('vfs://Test/Configuration/PackageStates.php');
     $composerNameToPackageKeyMap = array('typo3/flow' => 'TYPO3.Flow');
     $this->inject($this->packageManager, 'composerNameToPackageKeyMap', $composerNameToPackageKeyMap);
     $this->inject($this->packageManager, 'packagesBasePath', 'vfs://Test/Packages/');
     $this->mockDispatcher = $this->getMockBuilder(Dispatcher::class)->disableOriginalConstructor()->getMock();
     $this->inject($this->packageManager, 'dispatcher', $this->mockDispatcher);
     $this->packageManager->initialize($this->mockBootstrap);
 }
Ejemplo n.º 3
0
 /**
  * Sets up this test case
  *
  */
 protected function setUp()
 {
     vfsStream::setup('Test');
     $mockBootstrap = $this->getMock('TYPO3\\CMS\\Core\\Core\\Bootstrap', array(), array(), '', FALSE);
     $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', array('has', 'set', 'getBackend'), array(), '', FALSE);
     $mockCacheBackend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\SimpleFileBackend', array('has', 'set', 'getBackend'), array(), '', FALSE);
     $mockCache->expects($this->any())->method('has')->will($this->returnValue(FALSE));
     $mockCache->expects($this->any())->method('set')->will($this->returnValue(TRUE));
     $mockCache->expects($this->any())->method('getBackend')->will($this->returnValue($mockCacheBackend));
     $mockCacheBackend->expects($this->any())->method('getCacheDirectory')->will($this->returnValue('vfs://Test/Cache'));
     $this->packageManager = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Package\\PackageManager', array('sortAndSavePackageStates'));
     mkdir('vfs://Test/Packages/Application', 0700, TRUE);
     mkdir('vfs://Test/Configuration');
     file_put_contents('vfs://Test/Configuration/PackageStates.php', "<?php return array ('packages' => array(), 'version' => 4); ");
     $mockClassLoader = $this->getMock('TYPO3\\CMS\\Core\\Core\\ClassLoader', array(), array(\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getApplicationContext()));
     $mockClassLoader->expects($this->any())->method('setCacheIdentifier')->will($this->returnSelf());
     $composerNameToPackageKeyMap = array('typo3/flow' => 'TYPO3.Flow');
     $this->packageManager->injectClassLoader($mockClassLoader);
     $this->packageManager->injectCoreCache($mockCache);
     $this->inject($this->packageManager, 'composerNameToPackageKeyMap', $composerNameToPackageKeyMap);
     $this->packageManager->_set('packagesBasePath', 'vfs://Test/Packages/');
     $this->packageManager->_set('packageStatesPathAndFilename', 'vfs://Test/Configuration/PackageStates.php');
     $this->packageManager->initialize($mockBootstrap);
 }