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