1<?php
2
3namespace Sabre\DAV\Xml\Request;
4
5use Sabre\DAV\Xml\XmlTest;
6use Sabre\DAV\Xml\Property\Href;
7
8class PropPatchTest extends XmlTest {
9
10    function testSerialize() {
11
12        $propPatch = new PropPatch();
13        $propPatch->properties = [
14            '{DAV:}displayname' => 'Hello!',
15            '{DAV:}delete-me'   => null,
16            '{DAV:}some-url'    => new Href('foo/bar')
17        ];
18
19        $result = $this->write(
20            ['{DAV:}propertyupdate' => $propPatch]
21        );
22
23        $expected = <<<XML
24<?xml version="1.0"?>
25<d:propertyupdate xmlns:d="DAV:">
26    <d:set>
27        <d:prop>
28            <d:displayname>Hello!</d:displayname>
29        </d:prop>
30    </d:set>
31    <d:remove>
32        <d:prop>
33          <d:delete-me />
34        </d:prop>
35    </d:remove>
36    <d:set>
37        <d:prop>
38            <d:some-url>
39                <d:href>/foo/bar</d:href>
40            </d:some-url>
41        </d:prop>
42    </d:set>
43</d:propertyupdate>
44XML;
45
46        $this->assertXmlStringEqualsXmlString(
47            $expected,
48            $result
49        );
50
51    }
52
53}
54