Skip to content
This repository
Browse code

CLI bootstrap: Merge existing $_GET and $_REQUEST data

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...
commit 85480142c133cbeaf844c0dcdd21f06fc53184c7 1 parent cd0a1ff
Ingo Schommer authored July 04, 2012
5  cli-script.php
@@ -37,7 +37,8 @@
37 37
  */
38 38
 if(isset($_SERVER['argv'][2])) {
39 39
     $args = array_slice($_SERVER['argv'],2);
40  
-    $_GET = array();
  40
+    if(!isset($_GET)) $_GET = array();
  41
+    if(!isset($_REQUEST)) $_REQUEST = array();
41 42
     foreach($args as $arg) {
42 43
        if(strpos($arg,'=') == false) {
43 44
            $_GET['args'][] = $arg;
@@ -47,7 +48,7 @@
47 48
            $_GET = array_merge($_GET, $newItems);
48 49
        }
49 50
     }
50  
-	$_REQUEST = $_GET;
  51
+  $_REQUEST = array_merge($_REQUEST, $_GET);
51 52
 }
52 53
 
53 54
 // Set 'url' GET parameter
5  tests/bootstrap.php
@@ -28,7 +28,8 @@
28 28
 // Copied from cli-script.php, to enable same behaviour through phpunit runner.
29 29
 if(isset($_SERVER['argv'][2])) {
30 30
     $args = array_slice($_SERVER['argv'],2);
31  
-    $_GET = array();
  31
+    if(!isset($_GET)) $_GET = array();
  32
+    if(!isset($_REQUEST)) $_REQUEST = array();
32 33
     foreach($args as $arg) {
33 34
        if(strpos($arg,'=') == false) {
34 35
            $_GET['args'][] = $arg;
@@ -38,7 +39,7 @@
38 39
            $_GET = array_merge($_GET, $newItems);
39 40
        }
40 41
     }
41  
-	$_REQUEST = $_GET;
  42
+	$_REQUEST = array_merge($_REQUEST, $_GET);
42 43
 }
43 44
 
44 45
 // Always flush the manifest for phpunit test runs

0 notes on commit 8548014

Please sign in to comment.
Something went wrong with that request. Please try again.