xref: /plugin/davcal/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\DAVACL\Exception;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehleruse Sabre\DAV;
6*a1a3b679SAndreas Boehler
7*a1a3b679SAndreas Boehlerclass NoAbstractTest extends \PHPUnit_Framework_TestCase {
8*a1a3b679SAndreas Boehler
9*a1a3b679SAndreas Boehler    function testSerialize() {
10*a1a3b679SAndreas Boehler
11*a1a3b679SAndreas Boehler        $ex = new NoAbstract('message');
12*a1a3b679SAndreas Boehler
13*a1a3b679SAndreas Boehler        $server = new DAV\Server();
14*a1a3b679SAndreas Boehler        $dom = new \DOMDocument('1.0','utf-8');
15*a1a3b679SAndreas Boehler        $root = $dom->createElementNS('DAV:','d:root');
16*a1a3b679SAndreas Boehler        $dom->appendChild($root);
17*a1a3b679SAndreas Boehler
18*a1a3b679SAndreas Boehler        $ex->serialize($server, $root);
19*a1a3b679SAndreas Boehler
20*a1a3b679SAndreas Boehler        $xpaths = array(
21*a1a3b679SAndreas Boehler            '/d:root' => 1,
22*a1a3b679SAndreas Boehler            '/d:root/d:no-abstract' => 1,
23*a1a3b679SAndreas Boehler        );
24*a1a3b679SAndreas Boehler
25*a1a3b679SAndreas Boehler        // Reloading because PHP DOM sucks
26*a1a3b679SAndreas Boehler        $dom2 = new \DOMDocument('1.0', 'utf-8');
27*a1a3b679SAndreas Boehler        $dom2->loadXML($dom->saveXML());
28*a1a3b679SAndreas Boehler
29*a1a3b679SAndreas Boehler        $dxpath = new \DOMXPath($dom2);
30*a1a3b679SAndreas Boehler        $dxpath->registerNamespace('d','DAV:');
31*a1a3b679SAndreas Boehler        foreach($xpaths as $xpath=>$count) {
32*a1a3b679SAndreas Boehler
33*a1a3b679SAndreas Boehler            $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count);
34*a1a3b679SAndreas Boehler
35*a1a3b679SAndreas Boehler        }
36*a1a3b679SAndreas Boehler
37*a1a3b679SAndreas Boehler    }
38*a1a3b679SAndreas Boehler
39*a1a3b679SAndreas Boehler}
40