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