Merge remote-tracking branch 'upstream/4.3' into 4.3-4.4-2013-11-11-10-44-51
[civicrm-core.git] / tests / phpunit / CRM / Utils / GlobalStackTest.php
1 <?php
2
3 require_once 'CiviTest/CiviUnitTestCase.php';
4
5 class CRM_Utils_GlobalStackTest extends CiviUnitTestCase {
6
7 public function testPushPop() {
8 global $FOO, $EXTRA;
9
10 $FOO['bar'] = 1;
11 $FOO['whiz'] = 1;
12 $EXTRA = 1;
13
14 $this->assertEquals(1, $FOO['bar']);
15 $this->assertEquals(1, $FOO['whiz']);
16 $this->assertFalse(isset($FOO['bang']));
17 $this->assertEquals(1, $EXTRA);
18
19 CRM_Utils_GlobalStack::singleton()->push(array(
20 'FOO' => array(
21 'bar' => 2,
22 'bang' => 2,
23 ),
24 'EXTRA' => 2,
25 ));
26
27 $this->assertEquals(2, $FOO['bar']);
28 $this->assertEquals(1, $FOO['whiz']);
29 $this->assertEquals(2, $FOO['bang']);
30 $this->assertEquals(2, $EXTRA);
31
32 CRM_Utils_GlobalStack::singleton()->pop();
33
34 $this->assertEquals(1, $FOO['bar']);
35 $this->assertEquals(1, $FOO['whiz']);
36 $this->assertEquals(NULL, $FOO['bang']);
37 $this->assertEquals(1, $EXTRA);
38 }
39 }