mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Backported bootstrap.php changes from master and cstom TeamCity configuration (required to run tests through phpunit binary)
This commit is contained in:
parent
921bf9a439
commit
44b9d0560b
@ -1,12 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
// Simulate an execution from sapphire/cli-script.php, Core.php has too many
|
// Simulate an execution from sapphire/cli-script.php, Core.php has too many
|
||||||
// hardcoded assumptions about folder depth of the executing script.
|
// hardcoded assumptions about folder depth of the executing script.
|
||||||
|
//
|
||||||
|
// Make sure display_errors is on
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
// Overrides paths relative to this file (in sapphire/tests/FullTestSuite.php)
|
// Overrides paths relative to this file (in sapphire/tests/FullTestSuite.php)
|
||||||
$_SERVER['SCRIPT_FILENAME'] = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'cli-script.php';
|
global $_SERVER;
|
||||||
$_SERVER['SCRIPT_NAME'] = '.' . DIRECTORY_SEPARATOR . 'sapphire' . DIRECTORY_SEPARATOR . 'cli-script.php';
|
if (!$_SERVER) $_SERVER = array();
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = getcwd() . DIRECTORY_SEPARATOR . 'sapphire' . DIRECTORY_SEPARATOR . 'cli-script.php';
|
||||||
|
|
||||||
define('BASE_PATH', rtrim(dirname(dirname(dirname(__FILE__)))), DIRECTORY_SEPARATOR);
|
// Prepare manifest autoloader
|
||||||
|
function silverstripe_test_autoload($className) {
|
||||||
|
global $_CLASS_MANIFEST;
|
||||||
|
$lClassName = strtolower($className);
|
||||||
|
if(isset($_CLASS_MANIFEST[$lClassName])) include_once($_CLASS_MANIFEST[$lClassName]);
|
||||||
|
else if(isset($_CLASS_MANIFEST[$className])) include_once($_CLASS_MANIFEST[$className]);
|
||||||
|
}
|
||||||
|
spl_autoload_register('silverstripe_test_autoload');
|
||||||
|
|
||||||
|
require_once(getcwd()."/sapphire/core/Core.php");
|
||||||
|
|
||||||
// Copied from cli-script.php, to enable same behaviour through phpunit runner.
|
// Copied from cli-script.php, to enable same behaviour through phpunit runner.
|
||||||
if(isset($_SERVER['argv'][2])) {
|
if(isset($_SERVER['argv'][2])) {
|
||||||
@ -24,12 +37,44 @@ if(isset($_SERVER['argv'][2])) {
|
|||||||
$_REQUEST = $_GET;
|
$_REQUEST = $_GET;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!class_exists('Object')) {
|
// Now set a fake REQUEST_URI
|
||||||
require_once("sapphire/core/Core.php");
|
$_SERVER['REQUEST_URI'] = BASE_URL . '/dev/tests/all';
|
||||||
global $databaseConfig;
|
|
||||||
DB::connect($databaseConfig);
|
// 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SERVER['REQUEST_URI'] = BASE_URL . '/dev';
|
global $_ALL_CLASSES;
|
||||||
|
$_ALL_CLASSES['parents']['FakeController'] = array_merge($_ALL_CLASSES['parents']['Controller'], array('Controller' => 'Controller'));
|
||||||
|
|
||||||
|
$controller = new FakeController();
|
||||||
|
|
||||||
|
// Connect to database
|
||||||
|
global $databaseConfig;
|
||||||
|
|
||||||
|
require_once(getcwd()."/sapphire/core/model/DB.php");
|
||||||
|
DB::connect($databaseConfig);
|
||||||
|
|
||||||
|
// Get test manifest
|
||||||
ManifestBuilder::load_test_manifest();
|
ManifestBuilder::load_test_manifest();
|
Loading…
Reference in New Issue
Block a user