[FOLLOWUP][BUGFIX] Ignore transient class loading info in composer mode 91/44091/2
authorMarkus Klein <markus.klein@typo3.org>
Thu, 15 Oct 2015 18:54:58 +0000 (20:54 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 15 Oct 2015 19:06:07 +0000 (21:06 +0200)
Fix unit tests.

Resolves: #70689
Releases: master
Change-Id: Iff962536f565556d1579b34bdea26e82b149bcff
Reviewed-on: http://review.typo3.org/44091
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Tests/Unit/Package/PackageManagerTest.php

index 0fea6f0..76e7b57 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Package;
  */
 
 use TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement;
+use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Core\ClassLoadingInformation;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -33,7 +34,7 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
     protected $dependencyResolver;
 
     /**
-     * @var \TYPO3\CMS\Core\Core\Bootstrap
+     * @var Bootstrap
      */
     protected $bootstrap;
 
@@ -142,10 +143,11 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
     /**
      * Initializes the package manager
      *
-     * @param \TYPO3\CMS\Core\Core\Bootstrap $bootstrap The current bootstrap
+     * @param Bootstrap $bootstrap The current bootstrap
+     *
      * @return void
      */
-    public function initialize(\TYPO3\CMS\Core\Core\Bootstrap $bootstrap)
+    public function initialize(Bootstrap $bootstrap)
     {
         $this->bootstrap = $bootstrap;
 
@@ -679,7 +681,7 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
      */
     protected function registerTransientClassLoadingInformationForPackage(PackageInterface $package)
     {
-        if ($this->bootstrap->usesComposerClassLoading()) {
+        if (Bootstrap::usesComposerClassLoading()) {
             return;
         }
         ClassLoadingInformation::registerTransientClassLoadingInformationForPackage($package);
index 175b564..3066fe5 100644 (file)
@@ -11,6 +11,9 @@ namespace TYPO3\CMS\Core\Tests\Unit\Package;
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 
+use TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend;
+use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
+use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Package\DependencyResolver;
 use org\bovigo\vfs\vfsStream;
 use TYPO3\CMS\Core\Package\PackageManager;
@@ -34,9 +37,14 @@ class PackageManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     protected function setUp()
     {
         vfsStream::setup('Test');
-        $mockBootstrap = $this->getMock(\TYPO3\CMS\Core\Core\Bootstrap::class, array(), array(), '', false);
-        $mockCache = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class, array('has', 'set', 'getBackend'), array(), '', false);
-        $mockCacheBackend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::class, array('has', 'set', 'getBackend'), array(), '', false);
+
+        /** @var Bootstrap|\PHPUnit_Framework_MockObject_MockObject $mockBootstrap */
+        $mockBootstrap = $this->getMock(Bootstrap::class, array(), array(), '', false);
+        $mockBootstrap->method('usesComposerClassLoading')->will($this->returnValue(FALSE));
+
+        /** @var PhpFrontend|\PHPUnit_Framework_MockObject_MockObject $mockCache */
+        $mockCache = $this->getMock(PhpFrontend::class, array('has', 'set', 'getBackend'), array(), '', false);
+        $mockCacheBackend = $this->getMock(SimpleFileBackend::class, 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));
@@ -199,6 +207,7 @@ class PackageManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
             file_put_contents($packagePath . 'ext_emconf.php', '');
         }
 
+        /** @var PackageManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $packageManager */
         $packageManager = $this->getAccessibleMock(PackageManager::class, array('dummy'));
         $packageManager->_set('packagesBasePaths', array('local' => 'vfs://Test/Packages/Application'));
         $packageManager->_set('packagesBasePath', 'vfs://Test/Packages/');