From 85480142c133cbeaf844c0dcdd21f06fc53184c7 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 4 Jul 2012 12:05:31 +0200 Subject: [PATCH] CLI bootstrap: Merge existing $_GET and $_REQUEST data Necessary to have the directive working in phpunit.xml definitions, which in turns allows us to use GET parameters to switch the database connection for running automated tests. --- cli-script.php | 5 +++-- tests/bootstrap.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cli-script.php b/cli-script.php index e4391c619..2534bf688 100755 --- a/cli-script.php +++ b/cli-script.php @@ -37,7 +37,8 @@ chdir(dirname($_SERVER['SCRIPT_FILENAME'])); */ if(isset($_SERVER['argv'][2])) { $args = array_slice($_SERVER['argv'],2); - $_GET = array(); + if(!isset($_GET)) $_GET = array(); + if(!isset($_REQUEST)) $_REQUEST = array(); foreach($args as $arg) { if(strpos($arg,'=') == false) { $_GET['args'][] = $arg; @@ -47,7 +48,7 @@ if(isset($_SERVER['argv'][2])) { $_GET = array_merge($_GET, $newItems); } } - $_REQUEST = $_GET; + $_REQUEST = array_merge($_REQUEST, $_GET); } // Set 'url' GET parameter diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 199b9821c..490a1a0c2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -28,7 +28,8 @@ 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); - $_GET = array(); + if(!isset($_GET)) $_GET = array(); + if(!isset($_REQUEST)) $_REQUEST = array(); foreach($args as $arg) { if(strpos($arg,'=') == false) { $_GET['args'][] = $arg; @@ -38,7 +39,7 @@ if(isset($_SERVER['argv'][2])) { $_GET = array_merge($_GET, $newItems); } } - $_REQUEST = $_GET; + $_REQUEST = array_merge($_REQUEST, $_GET); } // Always flush the manifest for phpunit test runs