mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Allowing to run single tests via phpunit through new test bootstrap XML file (e.g. "phpunit sapphire/tests/api/RestfulServerTest.php" or "phpunit sapphire/tests/api") (from r111048)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112886 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
12d8b6994f
commit
064ccecd6b
@ -1,14 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
@require_once('sapphire/tests/bootstrap.php');
|
||||||
|
|
||||||
if(!class_exists('Object')) {
|
|
||||||
require_once("sapphire/core/Core.php");
|
|
||||||
global $databaseConfig;
|
|
||||||
DB::connect($databaseConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
//$c = new Controller;
|
|
||||||
//$c->pushCurrent();
|
|
||||||
|
|
||||||
class FullTestSuite {
|
class FullTestSuite {
|
||||||
public static function get_tests() {
|
public static function get_tests() {
|
||||||
|
37
tests/bootstrap.php
Executable file
37
tests/bootstrap.php
Executable file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
// Simulate an execution from sapphire/cli-script.php, Core.php has too many
|
||||||
|
// hardcoded assumptions about folder depth of the executing script.
|
||||||
|
|
||||||
|
// Overrides paths relative to this file (in sapphire/tests/FullTestSuite.php)
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'cli-script.php';
|
||||||
|
$_SERVER['SCRIPT_NAME'] = '.' . DIRECTORY_SEPARATOR . 'sapphire' . DIRECTORY_SEPARATOR . 'cli-script.php';
|
||||||
|
|
||||||
|
// Change to
|
||||||
|
chdir(dirname($_SERVER['SCRIPT_FILENAME']));
|
||||||
|
define('BASE_PATH', rtrim(dirname(dirname(dirname(__FILE__)))), DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
|
// Copied from cli-script.php, to enable same behaviour through phpunit runner.
|
||||||
|
if(isset($_SERVER['argv'][2])) {
|
||||||
|
$args = array_slice($_SERVER['argv'],2);
|
||||||
|
$_GET = array();
|
||||||
|
foreach($args as $arg) {
|
||||||
|
if(strpos($arg,'=') == false) {
|
||||||
|
$_GET['args'][] = $arg;
|
||||||
|
} else {
|
||||||
|
$newItems = array();
|
||||||
|
parse_str( (substr($arg,0,2) == '--') ? substr($arg,2) : $arg, $newItems );
|
||||||
|
$_GET = array_merge($_GET, $newItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_REQUEST = $_GET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!class_exists('Object')) {
|
||||||
|
require_once("core/Core.php");
|
||||||
|
global $databaseConfig;
|
||||||
|
DB::connect($databaseConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SERVER['REQUEST_URI'] = BASE_URL . '/dev';
|
||||||
|
|
||||||
|
ManifestBuilder::load_test_manifest();
|
Loading…
Reference in New Issue
Block a user