mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
ffe698ca1e
commit
517a0c9e48
22
tests/FakeController.php
Normal file
22
tests/FakeController.php
Normal 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();
|
||||
}
|
||||
}
|
@ -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'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user