INFRA-132 - CRM_Utils_GlobalStackTest
authorTim Otten <totten@civicrm.org>
Fri, 9 Jan 2015 00:28:29 +0000 (16:28 -0800)
committerTim Otten <totten@civicrm.org>
Fri, 9 Jan 2015 00:28:29 +0000 (16:28 -0800)
tests/phpunit/CRM/Utils/GlobalStackTest.php

index 6c2c417f7cc32df55738add53ee27265c424cac0..2da47681e50f1654525fe6669225c9497c62734e 100644 (file)
@@ -7,36 +7,40 @@ require_once 'CiviTest/CiviUnitTestCase.php';
  */
 class CRM_Utils_GlobalStackTest extends CiviUnitTestCase {
 
+  /**
+   * Temporarily override global variables and ensure that the variable data
+   * is set as expected (before/during/after the override).
+   */
   public function testPushPop() {
-    global $FOO, $EXTRA;
+    global $_FOO, $_EXTRA;
 
-    $FOO['bar'] = 1;
-    $FOO['whiz'] = 1;
-    $EXTRA = 1;
+    $_FOO['bar'] = 1;
+    $_FOO['whiz'] = 1;
+    $_EXTRA = 1;
 
-    $this->assertEquals(1, $FOO['bar']);
-    $this->assertEquals(1, $FOO['whiz']);
-    $this->assertFalse(isset($FOO['bang']));
-    $this->assertEquals(1, $EXTRA);
+    $this->assertEquals(1, $_FOO['bar']);
+    $this->assertEquals(1, $_FOO['whiz']);
+    $this->assertFalse(isset($_FOO['bang']));
+    $this->assertEquals(1, $_EXTRA);
 
     CRM_Utils_GlobalStack::singleton()->push(array(
-      'FOO' => array(
+      '_FOO' => array(
         'bar' => 2,
         'bang' => 2,
       ),
-      'EXTRA' => 2,
+      '_EXTRA' => 2,
     ));
 
-    $this->assertEquals(2, $FOO['bar']);
-    $this->assertEquals(1, $FOO['whiz']);
-    $this->assertEquals(2, $FOO['bang']);
-    $this->assertEquals(2, $EXTRA);
+    $this->assertEquals(2, $_FOO['bar']);
+    $this->assertEquals(1, $_FOO['whiz']);
+    $this->assertEquals(2, $_FOO['bang']);
+    $this->assertEquals(2, $_EXTRA);
 
     CRM_Utils_GlobalStack::singleton()->pop();
 
-    $this->assertEquals(1, $FOO['bar']);
-    $this->assertEquals(1, $FOO['whiz']);
-    $this->assertEquals(NULL, $FOO['bang']);
-    $this->assertEquals(1, $EXTRA);
+    $this->assertEquals(1, $_FOO['bar']);
+    $this->assertEquals(1, $_FOO['whiz']);
+    $this->assertEquals(NULL, $_FOO['bang']);
+    $this->assertEquals(1, $_EXTRA);
   }
 }