MINOR Moving FakeController class (required for bootstrap.php) into its own file, so that autoloading doesn't execute bootstrap (which is the case when invoking TestRunner->module())

This commit is contained in:
Ingo Schommer 2012-04-30 15:04:59 +02:00
parent ffe698ca1e
commit 517a0c9e48
2 changed files with 23 additions and 22 deletions

22
tests/FakeController.php Normal file
View File

@ -0,0 +1,22 @@
<?php
// Fake a current controller. Way harder than it should be
class FakeController extends Controller {
function __construct() {
parent::__construct();
$session = new Session(isset($_SESSION) ? $_SESSION : null);
$this->setSession($session);
$this->pushCurrent();
$this->request = new SS_HTTPRequest(
(isset($_SERVER['X-HTTP-Method-Override'])) ? $_SERVER['X-HTTP-Method-Override'] : $_SERVER['REQUEST_METHOD'],
'/'
);
$this->response = new SS_HTTPResponse();
$this->init();
}
}

View File

@ -15,7 +15,7 @@ $frameworkDir = basename($frameworkPath);
$_SERVER['SCRIPT_FILENAME'] = $frameworkPath . DIRECTORY_SEPARATOR . 'cli-script.php';
$_SERVER['SCRIPT_NAME'] = '.' . DIRECTORY_SEPARATOR . $frameworkDir . DIRECTORY_SEPARATOR . 'cli-script.php';
define('BASE_PATH', dirname($frameworkPath));
if(!defined('BASE_PATH')) define('BASE_PATH', dirname($frameworkPath));
// Copied from cli-script.php, to enable same behaviour through phpunit runner.
if(isset($_SERVER['argv'][2])) {
@ -47,27 +47,6 @@ $_SERVER['REQUEST_URI'] = BASE_URL . '/dev';
// Fake a session
$_SESSION = null;
// Fake a current controller. Way harder than it should be
class FakeController extends Controller {
function __construct() {
parent::__construct();
$session = new Session(isset($_SESSION) ? $_SESSION : null);
$this->setSession($session);
$this->pushCurrent();
$this->request = new SS_HTTPRequest(
(isset($_SERVER['X-HTTP-Method-Override'])) ? $_SERVER['X-HTTP-Method-Override'] : $_SERVER['REQUEST_METHOD'],
'/'
);
$this->response = new SS_HTTPResponse();
$this->init();
}
}
global $_ALL_CLASSES;
if(isset($_ALL_CLASSES)) {
$_ALL_CLASSES['parents']['FakeController'] = array_merge($_ALL_CLASSES['parents']['Controller'], array('Controller' => 'Controller'));