1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\DAV\Exception; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehleruse 6*a1a3b679SAndreas Boehler Sabre\DAV, 7*a1a3b679SAndreas Boehler DOMDocument; 8*a1a3b679SAndreas Boehler 9*a1a3b679SAndreas Boehlerclass LockedTest extends \PHPUnit_Framework_TestCase { 10*a1a3b679SAndreas Boehler 11*a1a3b679SAndreas Boehler function testSerialize() { 12*a1a3b679SAndreas Boehler 13*a1a3b679SAndreas Boehler $dom = new DOMDocument('1.0'); 14*a1a3b679SAndreas Boehler $dom->formatOutput = true; 15*a1a3b679SAndreas Boehler $root = $dom->createElement('d:root'); 16*a1a3b679SAndreas Boehler 17*a1a3b679SAndreas Boehler $dom->appendChild($root); 18*a1a3b679SAndreas Boehler $root->setAttribute('xmlns:d','DAV:'); 19*a1a3b679SAndreas Boehler 20*a1a3b679SAndreas Boehler $lockInfo = new DAV\Locks\LockInfo(); 21*a1a3b679SAndreas Boehler $lockInfo->uri = '/foo'; 22*a1a3b679SAndreas Boehler $locked = new Locked($lockInfo); 23*a1a3b679SAndreas Boehler 24*a1a3b679SAndreas Boehler $locked->serialize(new DAV\Server(), $root); 25*a1a3b679SAndreas Boehler 26*a1a3b679SAndreas Boehler $output = $dom->saveXML(); 27*a1a3b679SAndreas Boehler 28*a1a3b679SAndreas Boehler $expected = '<?xml version="1.0"?> 29*a1a3b679SAndreas Boehler<d:root xmlns:d="DAV:"> 30*a1a3b679SAndreas Boehler <d:lock-token-submitted xmlns:d="DAV:"> 31*a1a3b679SAndreas Boehler <d:href>/foo</d:href> 32*a1a3b679SAndreas Boehler </d:lock-token-submitted> 33*a1a3b679SAndreas Boehler</d:root> 34*a1a3b679SAndreas Boehler'; 35*a1a3b679SAndreas Boehler 36*a1a3b679SAndreas Boehler $this->assertEquals($expected, $output); 37*a1a3b679SAndreas Boehler 38*a1a3b679SAndreas Boehler } 39*a1a3b679SAndreas Boehler 40*a1a3b679SAndreas Boehler function testSerializeAmpersand() { 41*a1a3b679SAndreas Boehler 42*a1a3b679SAndreas Boehler $dom = new DOMDocument('1.0'); 43*a1a3b679SAndreas Boehler $dom->formatOutput = true; 44*a1a3b679SAndreas Boehler $root = $dom->createElement('d:root'); 45*a1a3b679SAndreas Boehler 46*a1a3b679SAndreas Boehler $dom->appendChild($root); 47*a1a3b679SAndreas Boehler $root->setAttribute('xmlns:d','DAV:'); 48*a1a3b679SAndreas Boehler 49*a1a3b679SAndreas Boehler $lockInfo = new DAV\Locks\LockInfo(); 50*a1a3b679SAndreas Boehler $lockInfo->uri = '/foo&bar'; 51*a1a3b679SAndreas Boehler $locked = new Locked($lockInfo); 52*a1a3b679SAndreas Boehler 53*a1a3b679SAndreas Boehler $locked->serialize(new DAV\Server(), $root); 54*a1a3b679SAndreas Boehler 55*a1a3b679SAndreas Boehler $output = $dom->saveXML(); 56*a1a3b679SAndreas Boehler 57*a1a3b679SAndreas Boehler $expected = '<?xml version="1.0"?> 58*a1a3b679SAndreas Boehler<d:root xmlns:d="DAV:"> 59*a1a3b679SAndreas Boehler <d:lock-token-submitted xmlns:d="DAV:"> 60*a1a3b679SAndreas Boehler <d:href>/foo&bar</d:href> 61*a1a3b679SAndreas Boehler </d:lock-token-submitted> 62*a1a3b679SAndreas Boehler</d:root> 63*a1a3b679SAndreas Boehler'; 64*a1a3b679SAndreas Boehler 65*a1a3b679SAndreas Boehler $this->assertEquals($expected, $output); 66*a1a3b679SAndreas Boehler 67*a1a3b679SAndreas Boehler } 68*a1a3b679SAndreas Boehler} 69