Skip to content

Commit

Permalink
CLI bootstrap: Merge existing $_GET and $_REQUEST data
Browse files Browse the repository at this point in the history
Necessary to have the <get name="db" /> directive
working in phpunit.xml definitions, which in turns allows
us to use GET parameters to switch the database connection
for running automated tests.
  • Loading branch information
chillu committed Jul 4, 2012
1 parent cd0a1ff commit 8548014
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cli-script.php
Expand Up @@ -37,7 +37,8 @@
*/
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;
Expand All @@ -47,7 +48,7 @@
$_GET = array_merge($_GET, $newItems);
}
}
$_REQUEST = $_GET;
$_REQUEST = array_merge($_REQUEST, $_GET);
}

// Set 'url' GET parameter
Expand Down
5 changes: 3 additions & 2 deletions tests/bootstrap.php
Expand Up @@ -28,7 +28,8 @@
// 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;
Expand All @@ -38,7 +39,7 @@
$_GET = array_merge($_GET, $newItems);
}
}
$_REQUEST = $_GET;
$_REQUEST = array_merge($_REQUEST, $_GET);
}

// Always flush the manifest for phpunit test runs
Expand Down

0 comments on commit 8548014

Please sign in to comment.