aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php
blob: c06d6aa1fc21b84ac27ca731ac4a0658f73ef8da (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php

namespace Sabre\DAV\Exception;

use
    Sabre\DAV,
    DOMDocument;

class LockedTest extends \PHPUnit_Framework_TestCase {

    function testSerialize() {

        $dom = new DOMDocument('1.0');
        $dom->formatOutput = true;
        $root = $dom->createElement('d:root');

        $dom->appendChild($root);
        $root->setAttribute('xmlns:d','DAV:');

        $lockInfo = new DAV\Locks\LockInfo();
        $lockInfo->uri = '/foo';
        $locked = new Locked($lockInfo);

        $locked->serialize(new DAV\Server(), $root);

        $output = $dom->saveXML();

        $expected = '<?xml version="1.0"?>
<d:root xmlns:d="DAV:">
  <d:lock-token-submitted xmlns:d="DAV:">
    <d:href>/foo</d:href>
  </d:lock-token-submitted>
</d:root>
';

        $this->assertEquals($expected, $output);

    }

    function testSerializeAmpersand() {

        $dom = new DOMDocument('1.0');
        $dom->formatOutput = true;
        $root = $dom->createElement('d:root');

        $dom->appendChild($root);
        $root->setAttribute('xmlns:d','DAV:');

        $lockInfo = new DAV\Locks\LockInfo();
        $lockInfo->uri = '/foo&bar';
        $locked = new Locked($lockInfo);

        $locked->serialize(new DAV\Server(), $root);

        $output = $dom->saveXML();

        $expected = '<?xml version="1.0"?>
<d:root xmlns:d="DAV:">
  <d:lock-token-submitted xmlns:d="DAV:">
    <d:href>/foo&amp;bar</d:href>
  </d:lock-token-submitted>
</d:root>
';

        $this->assertEquals($expected, $output);

    }
}