aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-10-21 15:46:31 -0700
committerfriendica <info@friendica.com>2013-10-21 15:46:31 -0700
commitb35122f7a6ad42756c35bb60ba1f06c3dcd45c77 (patch)
treeccdf373ce6475d264778523259cc32899b732fe7 /vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php
parente3504df514d306cfe6b83e44a11f550664564af4 (diff)
downloadvolse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.tar.gz
volse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.tar.bz2
volse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.zip
add sabre (1.8.x) via composer in the !@#$ place it wants to be
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php181
1 files changed, 181 insertions, 0 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php
new file mode 100644
index 000000000..be12c79ee
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php
@@ -0,0 +1,181 @@
+<?php
+
+namespace Sabre\DAVACL\Property;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class PrincipalTest extends \PHPUnit_Framework_TestCase {
+
+ function testSimple() {
+
+ $principal = new Principal(Principal::UNAUTHENTICATED);
+ $this->assertEquals(Principal::UNAUTHENTICATED, $principal->getType());
+ $this->assertNull($principal->getHref());
+
+ $principal = new Principal(Principal::AUTHENTICATED);
+ $this->assertEquals(Principal::AUTHENTICATED, $principal->getType());
+ $this->assertNull($principal->getHref());
+
+ $principal = new Principal(Principal::HREF,'admin');
+ $this->assertEquals(Principal::HREF, $principal->getType());
+ $this->assertEquals('admin',$principal->getHref());
+
+ }
+
+ /**
+ * @depends testSimple
+ * @expectedException Sabre\DAV\Exception
+ */
+ function testNoHref() {
+
+ $principal = new Principal(Principal::HREF);
+
+ }
+
+ /**
+ * @depends testSimple
+ */
+ function testSerializeUnAuthenticated() {
+
+ $prin = new Principal(Principal::UNAUTHENTICATED);
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:principal');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $objectTree = new DAV\ObjectTree(new DAV\SimpleCollection('rootdir'));
+ $server = new DAV\Server($objectTree);
+
+ $prin->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+'<d:unauthenticated/>' .
+'</d:principal>
+', $xml);
+
+ }
+
+
+ /**
+ * @depends testSerializeUnAuthenticated
+ */
+ function testSerializeAuthenticated() {
+
+ $prin = new Principal(Principal::AUTHENTICATED);
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:principal');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $objectTree = new DAV\ObjectTree(new DAV\SimpleCollection('rootdir'));
+ $server = new DAV\Server($objectTree);
+
+ $prin->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+'<d:authenticated/>' .
+'</d:principal>
+', $xml);
+
+ }
+
+
+ /**
+ * @depends testSerializeUnAuthenticated
+ */
+ function testSerializeHref() {
+
+ $prin = new Principal(Principal::HREF,'principals/admin');
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:principal');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $objectTree = new DAV\ObjectTree(new DAV\SimpleCollection('rootdir'));
+ $server = new DAV\Server($objectTree);
+
+ $prin->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+'<d:href>/principals/admin</d:href>' .
+'</d:principal>
+', $xml);
+
+ }
+
+ function testUnserializeHref() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+'<d:href>/principals/admin</d:href>' .
+'</d:principal>';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($xml);
+
+ $principal = Principal::unserialize($dom->firstChild);
+ $this->assertEquals(Principal::HREF, $principal->getType());
+ $this->assertEquals('/principals/admin', $principal->getHref());
+
+ }
+
+ function testUnserializeAuthenticated() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+' <d:authenticated />' .
+'</d:principal>';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($xml);
+
+ $principal = Principal::unserialize($dom->firstChild);
+ $this->assertEquals(Principal::AUTHENTICATED, $principal->getType());
+
+ }
+
+ function testUnserializeUnauthenticated() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+' <d:unauthenticated />' .
+'</d:principal>';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($xml);
+
+ $principal = Principal::unserialize($dom->firstChild);
+ $this->assertEquals(Principal::UNAUTHENTICATED, $principal->getType());
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ */
+ function testUnserializeUnknown() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+' <d:foo />' .
+'</d:principal>';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($xml);
+
+ Principal::unserialize($dom->firstChild);
+
+ }
+
+}