diff options
author | Thomas Citharel <tcit@tcit.fr> | 2016-08-01 17:16:30 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-09-26 11:55:40 +0200 |
commit | 9af2a9ff4d6984145aed3d3fe1312eee56fa8b74 (patch) | |
tree | 7110de0c78c03a2c4e5d29bc2430a4f7f0441b55 /apps/dav/tests/unit | |
parent | 691b3ab448907664a7fac29d1e8e795e1c6cd012 (diff) | |
download | nextcloud-server-9af2a9ff4d6984145aed3d3fe1312eee56fa8b74.tar.gz nextcloud-server-9af2a9ff4d6984145aed3d3fe1312eee56fa8b74.zip |
test serializer
Diffstat (limited to 'apps/dav/tests/unit')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php b/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php new file mode 100644 index 00000000000..b6b1e4381b5 --- /dev/null +++ b/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php @@ -0,0 +1,56 @@ +<?php + +namespace OCA\DAV\Tests\unit\CalDAV\Publishing; + +use OCA\DAV\CalDAV\Publishing\Xml\Publisher; +use Sabre\Xml\Writer; + +class PublisherTest extends \PHPUnit_Framework_TestCase { + + const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; + + public function testSerializePublished() { + $publish = new Publisher('urltopublish', true); + + $xml = $this->write([ + '{' . self::NS_CALENDARSERVER . '}publish-url' => $publish, + ]); + + $this->assertEquals('urltopublish', $publish->getValue()); + + $this->assertXmlStringEqualsXmlString( + '<?xml version="1.0"?> + <x1:publish-url xmlns:d="DAV:" xmlns:x1="' . self::NS_CALENDARSERVER . '"> + <d:href>urltopublish</d:href> + </x1:publish-url>', $xml); + } + + public function testSerializeNotPublished() { + $publish = new Publisher('urltopublish', false); + + $xml = $this->write([ + '{' . self::NS_CALENDARSERVER . '}pre-publish-url' => $publish, + ]); + + $this->assertEquals('urltopublish', $publish->getValue()); + + $this->assertXmlStringEqualsXmlString( + '<?xml version="1.0"?> + <x1:pre-publish-url xmlns:d="DAV:" xmlns:x1="' . self::NS_CALENDARSERVER . '">urltopublish</x1:pre-publish-url>', $xml); + } + + + protected $elementMap = []; + protected $namespaceMap = ['DAV:' => 'd']; + protected $contextUri = '/'; + + private function write($input) { + $writer = new Writer(); + $writer->contextUri = $this->contextUri; + $writer->namespaceMap = $this->namespaceMap; + $writer->openMemory(); + $writer->setIndent(true); + $writer->write($input); + return $writer->outputMemory(); + } +} |