aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/Property/ResourceTypeTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Property/ResourceTypeTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Property/ResourceTypeTest.php111
1 files changed, 111 insertions, 0 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Property/ResourceTypeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Property/ResourceTypeTest.php
new file mode 100644
index 000000000..8a579baec
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Property/ResourceTypeTest.php
@@ -0,0 +1,111 @@
+<?php
+
+namespace Sabre\DAV\Property;
+
+use Sabre\DAV;
+
+class ResourceTypeTest extends \PHPUnit_Framework_TestCase {
+
+ function testConstruct() {
+
+ $resourceType = new ResourceType(array('{DAV:}collection'));
+ $this->assertEquals(array('{DAV:}collection'),$resourceType->getValue());
+
+ $resourceType = new ResourceType(DAV\Server::NODE_FILE);
+ $this->assertEquals(array(),$resourceType->getValue());
+
+ $resourceType = new ResourceType(DAV\Server::NODE_DIRECTORY);
+ $this->assertEquals(array('{DAV:}collection'),$resourceType->getValue());
+
+ $resourceType = new ResourceType('{DAV:}principal');
+ $this->assertEquals(array('{DAV:}principal'),$resourceType->getValue());
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testSerialize() {
+
+ $resourceType = new ResourceType(array('{DAV:}collection','{DAV:}principal'));
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:anything');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+ $resourceType->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:collection/><d:principal/></d:anything>
+', $xml);
+
+ }
+
+ /**
+ * @depends testSerialize
+ */
+ function testSerializeCustomNS() {
+
+ $resourceType = new ResourceType(array('{http://example.org/NS}article'));
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:anything');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+ $resourceType->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><custom:article xmlns:custom="http://example.org/NS"/></d:anything>
+', $xml);
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testIs() {
+
+ $resourceType = new ResourceType(array('{DAV:}collection','{DAV:}principal'));
+ $this->assertTrue($resourceType->is('{DAV:}collection'));
+ $this->assertFalse($resourceType->is('{DAV:}blabla'));
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testAdd() {
+
+ $resourceType = new ResourceType(array('{DAV:}collection','{DAV:}principal'));
+ $resourceType->add('{DAV:}foo');
+ $this->assertEquals(array('{DAV:}collection','{DAV:}principal','{DAV:}foo'), $resourceType->getValue());
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testUnserialize() {
+
+ $xml ='<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:collection/><d:principal/></d:anything>
+';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($xml);
+
+ $resourceType = ResourceType::unserialize($dom->firstChild);
+ $this->assertEquals(array('{DAV:}collection','{DAV:}principal'),$resourceType->getValue());
+
+ }
+
+}