mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
0b1f297873
Conflicts: .travis.yml README.md admin/code/LeftAndMain.php admin/css/screen.css admin/scss/screen.scss api/RestfulService.php conf/ConfigureFromEnv.php control/injector/ServiceConfigurationLocator.php control/injector/SilverStripeServiceConfigurationLocator.php core/ClassInfo.php core/Object.php css/AssetUploadField.css css/ComplexTableField_popup.css dev/CSSContentParser.php dev/DevelopmentAdmin.php docs/en/changelogs/index.md docs/en/misc/contributing/code.md docs/en/reference/execution-pipeline.md filesystem/GD.php filesystem/ImagickBackend.php filesystem/Upload.php forms/Form.php forms/FormField.php forms/HtmlEditorConfig.php forms/gridfield/GridFieldDetailForm.php forms/gridfield/GridFieldSortableHeader.php lang/en.yml model/Aggregate.php model/DataList.php model/DataObject.php model/DataQuery.php model/Image.php model/MySQLDatabase.php model/SQLQuery.php model/fieldtypes/HTMLText.php model/fieldtypes/Text.php scss/AssetUploadField.scss search/filters/SearchFilter.php security/Authenticator.php security/LoginForm.php security/Member.php security/MemberAuthenticator.php security/MemberLoginForm.php security/Security.php tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php tests/control/HTTPTest.php tests/control/RequestHandlingTest.php tests/filesystem/UploadTest.php tests/forms/FormTest.php tests/forms/NumericFieldTest.php tests/model/DataListTest.php tests/model/DataObjectTest.php tests/model/TextTest.php tests/security/MemberAuthenticatorTest.php tests/security/SecurityDefaultAdminTest.php tests/view/SSViewerCacheBlockTest.php tests/view/SSViewerTest.php
69 lines
1.8 KiB
PHP
69 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This bootstraps the SilverStripe system so that phpunit can be run directly on SilverStripe tests.
|
|
*/
|
|
|
|
// Make sure display_errors is on
|
|
ini_set('display_errors', 1);
|
|
|
|
// Check we're using at least PHPUnit 3.5
|
|
if(version_compare(PHPUnit_Runner_Version::id(), '3.5', '<')) {
|
|
echo 'PHPUnit 3.5 required to run tests using bootstrap.php';
|
|
die();
|
|
}
|
|
|
|
// Fake the script name and base
|
|
global $_SERVER;
|
|
if (!$_SERVER) $_SERVER = array();
|
|
|
|
$frameworkPath = dirname(dirname(__FILE__));
|
|
$frameworkDir = basename($frameworkPath);
|
|
|
|
$_SERVER['SCRIPT_FILENAME'] = $frameworkPath . DIRECTORY_SEPARATOR . 'cli-script.php';
|
|
$_SERVER['SCRIPT_NAME'] = '.' . DIRECTORY_SEPARATOR . $frameworkDir . DIRECTORY_SEPARATOR . 'cli-script.php';
|
|
|
|
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])) {
|
|
$args = array_slice($_SERVER['argv'],2);
|
|
if(!isset($_GET)) $_GET = array();
|
|
if(!isset($_REQUEST)) $_REQUEST = 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 = array_merge($_REQUEST, $_GET);
|
|
}
|
|
|
|
// Connect to database
|
|
require_once $frameworkPath . '/core/Core.php';
|
|
require_once $frameworkPath . '/tests/FakeController.php';
|
|
|
|
global $databaseConfig;
|
|
DB::connect($databaseConfig);
|
|
|
|
// Now set a fake REQUEST_URI
|
|
$_SERVER['REQUEST_URI'] = BASE_URL . '/dev';
|
|
|
|
// Fake a session
|
|
$_SESSION = null;
|
|
|
|
// Prepare manifest autoloader
|
|
$controller = new FakeController();
|
|
|
|
// Get test manifest
|
|
TestRunner::use_test_manifest();
|
|
|
|
SapphireTest::set_is_running_test(true);
|
|
|
|
// Remove the error handler so that PHPUnit can add its own
|
|
restore_error_handler();
|
|
|