From ccd1cf98323265b94a74a81baa8732575f6fc7e5 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 8 Jan 2015 16:28:29 -0800 Subject: [PATCH] INFRA-132 - CRM_Utils_GlobalStackTest --- tests/phpunit/CRM/Utils/GlobalStackTest.php | 40 +++++++++++---------- 1 file changed, 22 insertions(+), 18 deletions(-) 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); } } -- 2.25.1