From ddb96b9dbdaeee892dae4b5b8e5400d0723f73fb Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 16 Jan 2008 05:24:27 +0000 Subject: [PATCH] Added Makefile so that you can execute 'make test' in sapphire and it will run tests. Added support for array in _ss_environment.php for specifying URLs to use for cli-script.php git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@48093 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- Makefile | 6 ++++++ cli-script.php | 27 +++++++++++++++++++++++++-- core/control/SapphireInfo.php | 11 +++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Makefile create mode 100644 core/control/SapphireInfo.php diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..16eea71e9 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +URL=`./cli-script.php SapphireInfo/baseurl` + +test: windmill + +windmill: + functest ../cms/tests/test_windmill url=${URL}admin browser=firefox diff --git a/cli-script.php b/cli-script.php index 1cb51d6e6..e12c707c9 100755 --- a/cli-script.php +++ b/cli-script.php @@ -72,6 +72,24 @@ foreach($envFiles as $envFile) { } } +// Find the URL of this script +if(isset($_FILE_TO_URL_MAPPING)) { + $fullPath = $testPath = $_SERVER['SCRIPT_FILENAME']; + while($testPath && $testPath != "/") { + if(isset($_FILE_TO_URL_MAPPING[$testPath])) { + $url = $_FILE_TO_URL_MAPPING[$testPath] . substr($fullPath,strlen($testPath)); + $_SERVER['HTTP_HOST'] = parse_url($url, PHP_URL_HOST); + $_SERVER['SCRIPT_NAME'] = parse_url($url, PHP_URL_PATH); + $_SERVER['REQUEST_PORT'] = parse_url($url, PHP_URL_PORT); + break; + } + $testPath = dirname($testPath); + } + +} + + + if(ManifestBuilder::staleManifest()){ ManifestBuilder::compileManifest(); } @@ -80,7 +98,7 @@ require_once(MANIFEST_FILE); if($_GET['debugmanifest']) Debug::show(file_get_contents(MANIFEST_FILE)); -Director::set_environment_type($envType); +if(!isset(Director::$environment_type)) Director::set_environment_type($envType); // Default director Director::addRules(10, array( @@ -103,9 +121,14 @@ DB::connect($databaseConfig); // Get the request URL // $baseURL = dirname(dirname($_SERVER[SCRIPT_NAME])); -$url = $_GET['url']; $url = $_SERVER['argv'][1]; +if(isset($_SERVER['argv'][2])) { + parse_str($_SERVER['argv'][2], $_GET); + $_REQUEST = $_GET; + print_r($_GET); + +} // Direct away - this is the "main" function, that hands control to the apporopriate controllerx Director::direct($url); diff --git a/core/control/SapphireInfo.php b/core/control/SapphireInfo.php new file mode 100644 index 000000000..f8b4685e5 --- /dev/null +++ b/core/control/SapphireInfo.php @@ -0,0 +1,11 @@ +