From: Tim Otten Date: Fri, 9 Jan 2015 00:28:29 +0000 (-0800) Subject: INFRA-132 - CRM_Utils_GlobalStackTest X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ccd1cf98323265b94a74a81baa8732575f6fc7e5;p=civicrm-core.git INFRA-132 - CRM_Utils_GlobalStackTest --- diff --git a/tests/phpunit/CRM/Utils/GlobalStackTest.php b/tests/phpunit/CRM/Utils/GlobalStackTest.php index 6c2c417f7c..2da47681e5 100644 --- a/tests/phpunit/CRM/Utils/GlobalStackTest.php +++ b/tests/phpunit/CRM/Utils/GlobalStackTest.php @@ -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); } }