[BUGFIX] Skip unit test depending on Composer mode 26/44026/2
authorNicole Cordes <typo3@cordes.co>
Tue, 13 Oct 2015 09:24:14 +0000 (11:24 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 22 Oct 2015 08:54:32 +0000 (10:54 +0200)
The test isCoreUpdateEnabledReturnsTrueForEnvironmentVariableNotSet in
\TYPO3\CMS\Install\Service\CoreUpdateServiceTest depends on the
TYPO3_COMPOSER_MODE environment variable. This test should be skipped
if unit tests are running in Composer mode. An additional test for the
Composer mode is added to ensure the updater returns false.

Resolves: #70648
Releases: master
Change-Id: Iaedd9d0ab2c3877924fc41a6f9e2d4692c6d2f0a
Reviewed-on: https://review.typo3.org/44026
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/install/Tests/Unit/Service/CoreUpdateServiceTest.php

index 73f7a3e..819cc79 100644 (file)
@@ -36,6 +36,9 @@ class CoreUpdateServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function isCoreUpdateEnabledReturnsTrueForEnvironmentVariableNotSet()
     {
+        if (defined('TYPO3_COMPOSER_MODE') && TYPO3_COMPOSER_MODE) {
+            $this->markTestSkipped('This test is only available in Non-Composer mode.');
+        }
         /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
         $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\CoreUpdateService::class, array('dummy'), array(), '', false);
         putenv('TYPO3_DISABLE_CORE_UPDATER');
@@ -66,4 +69,17 @@ class CoreUpdateServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         putenv('REDIRECT_TYPO3_DISABLE_CORE_UPDATER=1');
         $this->assertFalse($instance->isCoreUpdateEnabled());
     }
+
+    /**
+     * @test
+     */
+    public function isCoreUpdateEnabledReturnsFalseFor_TYPO3_COMPOSER_MODE_EnvironmentVariableSet()
+    {
+        if (!defined('TYPO3_COMPOSER_MODE')) {
+            putenv('TYPO3_COMPOSER_MODE=1');
+        }
+        /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
+        $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\CoreUpdateService::class, array('dummy'), array(), '', false);
+        $this->assertFalse($instance->isCoreUpdateEnabled());
+    }
 }