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