2010-10-19 05:41:34 +02:00
|
|
|
<?php
|
2012-03-24 04:38:57 +01:00
|
|
|
// Simulate an execution from framework/cli-script.php, Core.php has too many
|
2010-10-19 05:41:34 +02:00
|
|
|
// hardcoded assumptions about folder depth of the executing script.
|
|
|
|
|
2011-12-04 13:35:06 +01:00
|
|
|
// Make sure display_errors is on
|
|
|
|
ini_set('display_errors', 1);
|
|
|
|
|
|
|
|
// Fake the script name and base
|
|
|
|
global $_SERVER;
|
|
|
|
if (!$_SERVER) $_SERVER = array();
|
|
|
|
|
2012-03-24 04:38:57 +01:00
|
|
|
$frameworkPath = dirname(dirname(__FILE__));
|
|
|
|
$frameworkDir = basename($frameworkPath);
|
2010-10-19 05:41:34 +02:00
|
|
|
|
2012-03-24 04:38:57 +01:00
|
|
|
$_SERVER['SCRIPT_FILENAME'] = $frameworkPath . DIRECTORY_SEPARATOR . 'cli-script.php';
|
|
|
|
$_SERVER['SCRIPT_NAME'] = '.' . DIRECTORY_SEPARATOR . $frameworkDir . DIRECTORY_SEPARATOR . 'cli-script.php';
|
|
|
|
|
2012-04-30 15:04:59 +02:00
|
|
|
if(!defined('BASE_PATH')) define('BASE_PATH', dirname($frameworkPath));
|
2010-10-19 05:41:34 +02:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2012-01-10 05:28:11 +01:00
|
|
|
// Always flush the manifest for phpunit test runs
|
|
|
|
$_GET['flush'] = 1;
|
|
|
|
|
2011-12-04 13:35:06 +01:00
|
|
|
// Connect to database
|
2012-03-24 04:38:57 +01:00
|
|
|
require_once($frameworkPath . "/core/Core.php");
|
2011-12-04 13:35:06 +01:00
|
|
|
global $databaseConfig;
|
|
|
|
DB::connect($databaseConfig);
|
2010-10-19 05:41:34 +02:00
|
|
|
|
2011-12-04 13:35:06 +01:00
|
|
|
// Now set a fake REQUEST_URI
|
2010-10-19 05:41:34 +02:00
|
|
|
$_SERVER['REQUEST_URI'] = BASE_URL . '/dev';
|
|
|
|
|
2011-12-04 13:35:06 +01:00
|
|
|
// Fake a session
|
|
|
|
$_SESSION = null;
|
|
|
|
|
|
|
|
global $_ALL_CLASSES;
|
|
|
|
if(isset($_ALL_CLASSES)) {
|
|
|
|
$_ALL_CLASSES['parents']['FakeController'] = array_merge($_ALL_CLASSES['parents']['Controller'], array('Controller' => 'Controller'));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare manifest autoloader
|
|
|
|
$controller = new FakeController();
|
|
|
|
|
|
|
|
// Get test manifest
|
2011-12-04 13:10:28 +01:00
|
|
|
TestRunner::use_test_manifest();
|
|
|
|
|
|
|
|
// Remove the error handler so that PHPUnit can add its own
|
2012-03-24 04:38:57 +01:00
|
|
|
restore_error_handler();
|