X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/blobdiff_plain/4177a069286c363deed655346f9290f888f69704..4c6ec4df4d381bb5f8aef3f9b55acd3cefe1735c:/typo3/sysext/core/Build/FunctionalTestsBootstrap.php diff --git a/typo3/sysext/core/Build/FunctionalTestsBootstrap.php b/typo3/sysext/core/Build/FunctionalTestsBootstrap.php index d52ada0da6a5..afa82459edd5 100644 --- a/typo3/sysext/core/Build/FunctionalTestsBootstrap.php +++ b/typo3/sysext/core/Build/FunctionalTestsBootstrap.php @@ -1,6 +1,4 @@ enableDisplayErrors() - ->loadClassFiles() - ->defineOriginalRootPath() - ->createNecessaryDirectoriesInDocumentRoot(); - } - - /** - * Makes sure error messages during the tests get displayed no matter what is set in php.ini. - * - * @return FunctionalTestsBootstrap fluent interface - */ - protected function enableDisplayErrors() - { - @ini_set('display_errors', 1); - return $this; - } - - /** - * Requires classes the functional test classes extend from or use for further bootstrap. - * Only files required for "new TestCaseClass" are required here and a general exception - * that is thrown by setUp() code. - * - * @return FunctionalTestsBootstrap fluent interface - */ - protected function loadClassFiles() - { - if (!class_exists('PHPUnit_Framework_TestCase')) { - die('PHPUnit wasn\'t found. Please check your settings and command.'); - } - if (!class_exists(BaseTestCase::class)) { - // PHPUnit is invoked globally, so we need to include the project autoload file - require_once __DIR__ . '/../../../../vendor/autoload.php'; - } - - return $this; - } - - /** - * Defines the constant ORIGINAL_ROOT for the path to the original TYPO3 document root. - * - * If ORIGINAL_ROOT already is defined, this method is a no-op. - * - * @return FunctionalTestsBootstrap fluent interface - */ - protected function defineOriginalRootPath() - { - if (!defined('ORIGINAL_ROOT')) { - /** @var string */ - define('ORIGINAL_ROOT', $this->getWebRoot()); - } - - if (!file_exists(ORIGINAL_ROOT . 'typo3/cli_dispatch.phpsh')) { - die('Unable to determine path to entry script. Please check your path or set an environment variable \'TYPO3_PATH_WEB\' to your root path.'); - } - - return $this; - } - - /** - * Creates the following directories in the TYPO3 core: - * - typo3temp - * - * @return FunctionalTestsBootstrap fluent interface - */ - protected function createNecessaryDirectoriesInDocumentRoot() - { - $this->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests'); - $this->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient'); - - return $this; - } - - /** - * Creates the directory $directory (recursively if required). - * - * If $directory already exists, this method is a no-op. - * - * @param string $directory absolute path of the directory to be created - * @return void - * @throws \RuntimeException - */ - protected function createDirectory($directory) - { - if (is_dir($directory)) { - return; - } - @mkdir($directory, 0777, true); - clearstatcache(); - if (!is_dir($directory)) { - throw new \RuntimeException('Directory "' . $directory . '" could not be created', 1404038665); - } - } - /** - * Returns the absolute path the TYPO3 document root. - * - * @return string the TYPO3 document root using Unix path separators - */ - protected function getWebRoot() - { - if (getenv('TYPO3_PATH_WEB')) { - $webRoot = getenv('TYPO3_PATH_WEB'); - } else { - $webRoot = getcwd(); - } - return rtrim(strtr($webRoot, '\\', '/'), '/') . '/'; +call_user_func(function () { + // Ensure cli only as security measure + if (PHP_SAPI !== 'cli') { + die('This script supports command line usage only. Please check your command.'); } -} -if (PHP_SAPI !== 'cli') { - die('This script supports command line usage only. Please check your command.'); -} -$bootstrap = new FunctionalTestsBootstrap(); -$bootstrap->bootstrapSystem(); -unset($bootstrap); + $testbase = new \TYPO3\CMS\Core\Tests\Testbase(); + $testbase->enableDisplayErrors(); + $testbase->defineBaseConstants(); + $testbase->defineOriginalRootPath(); + $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests'); + $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient'); +}); \ No newline at end of file