TYPO3 CMS  TYPO3_6-2
FunctionalTestsBootstrap.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
28  public function bootstrapSystem() {
29  $this->enableDisplayErrors()
30  ->loadClassFiles()
31  ->defineOriginalRootPath()
32  ->createNecessaryDirectoriesInDocumentRoot();
33  }
34 
40  protected function enableDisplayErrors() {
41  @ini_set('display_errors', 1);
42  return $this;
43  }
44 
52  protected function loadClassFiles() {
53  $testsDirectory = __DIR__ . '/../Tests/';
54  if (!class_exists('PHPUnit_Framework_TestCase')) {
55  die('PHPUnit wasn\'t found. Please check your settings and command.');
56  }
57  require_once($testsDirectory . 'BaseTestCase.php');
58  require_once($testsDirectory . 'FunctionalTestCase.php');
59  require_once($testsDirectory . 'FunctionalTestCaseBootstrapUtility.php');
60  require_once($testsDirectory . 'Exception.php');
61 
62  return $this;
63  }
64 
72  protected function defineOriginalRootPath() {
73  if (!defined('ORIGINAL_ROOT')) {
75  define('ORIGINAL_ROOT', $this->getWebRoot());
76  }
77 
78  return $this;
79  }
80 
88  $this->createDirectory(ORIGINAL_ROOT . 'typo3temp');
89 
90  return $this;
91  }
92 
102  protected function createDirectory($directory) {
103  if (is_dir($directory)) {
104  return;
105  }
106 
107  if (!mkdir($directory, 0777, TRUE)) {
108  throw new \RuntimeException('Directory "' . $directory . '" could not be created', 1404038665);
109  }
110  }
111 
117  protected function getWebRoot() {
118  if (getenv('TYPO3_PATH_WEB')) {
119  $webRoot = getenv('TYPO3_PATH_WEB') . '/';
120  } else {
121  $webRoot = getcwd() . '/';
122  }
123 
124  return strtr($webRoot, '\\', '/');
125  }
126 }
127 
128 if (PHP_SAPI !== 'cli') {
129  die('This script supports command line usage only. Please check your command.');
130 }
131 
133 $bootstrap->bootstrapSystem();
134 unset($bootstrap);
if(PHP_SAPI !=='cli') $bootstrap
die
Definition: index.php:6