[TASK] Simplify test bootstrap 36/47436/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 30 Mar 2016 17:40:09 +0000 (19:40 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 30 Mar 2016 18:02:44 +0000 (20:02 +0200)
If moving the CLI test for unit and functionals to the Basetest
class, the patch from issue #75321 can be simplified a bit since
we are sure all test suites are executed in CLI only so no
HTTP headers need to be sent.

Change-Id: Ic11abeae72c86d6c6c0e879d4e07eee6bc55ffab
Resolves: #75321
Related: #75280
Releases: master
Reviewed-on: https://review.typo3.org/47436
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Build/FunctionalTestsBootstrap.php
typo3/sysext/core/Build/UnitTestsBootstrap.php
typo3/sysext/core/Tests/AcceptanceCoreEnvironment.php
typo3/sysext/core/Tests/Testbase.php

index ef93610..1c6a45a 100644 (file)
  * with phpunit parameter --bootstrap if executing single test case classes.
  */
 call_user_func(function () {
-    // Ensure cli only as security measure
-    if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
-        die('This script supports command line usage only. Please check your command.');
-    }
-
     $testbase = new \TYPO3\CMS\Core\Tests\Testbase();
     $testbase->enableDisplayErrors();
     $testbase->defineBaseConstants();
index 9f43e47..edb0cd2 100644 (file)
  *     typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php
  */
 call_user_func(function () {
-    // Ensure cli only as security measure
-    if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
-        die('This script supports command line usage only. Please check your command.');
-    }
-
     $testbase = new \TYPO3\CMS\Core\Tests\Testbase();
     $testbase->enableDisplayErrors();
     $testbase->defineBaseConstants();
index d516503..69f3c15 100644 (file)
@@ -159,7 +159,6 @@ class AcceptanceCoreEnvironment extends Extension
 
         $instancePath = ORIGINAL_ROOT . 'typo3temp/var/tests/acceptance';
 
-        $testbase = new Testbase();
         $testbase->defineTypo3ModeBe();
         $testbase->setTypo3TestingContext();
         $testbase->removeOldInstanceIfExists($instancePath);
index 2c20805..d0bafa3 100644 (file)
@@ -33,6 +33,18 @@ use TYPO3\CMS\Install\Service\SqlSchemaMigrationService;
  */
 class Testbase
 {
+    /**
+     * This class must be called in CLI environment as a security measure
+     * against path disclosures and other stuff. Check this within
+     * constructor to make sure this check can't be circumvented.
+     */
+    public function __construct()
+    {
+        // Ensure cli only as security measure
+        if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
+            die('This script supports command line usage only. Please check your command.');
+        }
+    }
 
     /**
      * Makes sure error messages during the tests get displayed no matter what is set in php.ini.
@@ -696,15 +708,6 @@ class Testbase
      */
     protected function exitWithMessage($message)
     {
-        $headers = [
-            \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_500,
-            'Content-type: text/plain'
-        ];
-        if (!headers_sent()) {
-            foreach ($headers as $header) {
-                header($header);
-            }
-        }
         echo $message . LF;
         exit(1);
     }