1<?php
2
3namespace Sabre\Xml;
4
5/**
6 * Test for the ContextStackTrait
7 *
8 * @copyright Copyright (C) 2009-2015 fruux GmbH (https://fruux.com/).
9 * @author Evert Pot (http://evertpot.com/)
10 * @license http://sabre.io/license/ Modified BSD License
11 */
12class ContextStackTest extends \PHPUnit_Framework_TestCase {
13
14    function setUp() {
15
16        $this->stack = $this->getMockForTrait('Sabre\\Xml\\ContextStackTrait');
17
18    }
19
20    function testPushAndPull() {
21
22        $this->stack->contextUri = '/foo/bar';
23        $this->stack->elementMap['{DAV:}foo'] = 'Bar';
24        $this->stack->namespaceMap['DAV:'] = 'd';
25
26        $this->stack->pushContext();
27
28        $this->assertEquals('/foo/bar', $this->stack->contextUri);
29        $this->assertEquals('Bar', $this->stack->elementMap['{DAV:}foo']);
30        $this->assertEquals('d', $this->stack->namespaceMap['DAV:']);
31
32        $this->stack->contextUri = '/gir/zim';
33        $this->stack->elementMap['{DAV:}foo'] = 'newBar';
34        $this->stack->namespaceMap['DAV:'] = 'dd';
35
36        $this->stack->popContext();
37
38        $this->assertEquals('/foo/bar', $this->stack->contextUri);
39        $this->assertEquals('Bar', $this->stack->elementMap['{DAV:}foo']);
40        $this->assertEquals('d', $this->stack->namespaceMap['DAV:']);
41
42    }
43
44}
45