Commit | Line | Data |
---|---|---|
6d4b9264 TO |
1 | <?php |
2 | ||
3 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
4 | ||
aba1cd8b EM |
5 | /** |
6 | * Class CRM_Utils_GlobalStackTest | |
7 | */ | |
6d4b9264 TO |
8 | class CRM_Utils_GlobalStackTest extends CiviUnitTestCase { |
9 | ||
10 | public function testPushPop() { | |
25c8f5c6 | 11 | global $FOO, $EXTRA; |
6d4b9264 TO |
12 | |
13 | $FOO['bar'] = 1; | |
14 | $FOO['whiz'] = 1; | |
25c8f5c6 | 15 | $EXTRA = 1; |
6d4b9264 TO |
16 | |
17 | $this->assertEquals(1, $FOO['bar']); | |
18 | $this->assertEquals(1, $FOO['whiz']); | |
19 | $this->assertFalse(isset($FOO['bang'])); | |
25c8f5c6 | 20 | $this->assertEquals(1, $EXTRA); |
6d4b9264 TO |
21 | |
22 | CRM_Utils_GlobalStack::singleton()->push(array( | |
23 | 'FOO' => array( | |
24 | 'bar' => 2, | |
25 | 'bang' => 2, | |
26 | ), | |
25c8f5c6 | 27 | 'EXTRA' => 2, |
6d4b9264 TO |
28 | )); |
29 | ||
30 | $this->assertEquals(2, $FOO['bar']); | |
31 | $this->assertEquals(1, $FOO['whiz']); | |
32 | $this->assertEquals(2, $FOO['bang']); | |
25c8f5c6 | 33 | $this->assertEquals(2, $EXTRA); |
6d4b9264 TO |
34 | |
35 | CRM_Utils_GlobalStack::singleton()->pop(); | |
36 | ||
37 | $this->assertEquals(1, $FOO['bar']); | |
38 | $this->assertEquals(1, $FOO['whiz']); | |
39 | $this->assertEquals(NULL, $FOO['bang']); | |
25c8f5c6 | 40 | $this->assertEquals(1, $EXTRA); |
6d4b9264 TO |
41 | } |
42 | } |