assertEquals(Sabre_DAVACL_Property_Principal::UNAUTHENTICATED, $principal->getType());
$this->assertNull($principal->getHref());
$principal = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::AUTHENTICATED);
$this->assertEquals(Sabre_DAVACL_Property_Principal::AUTHENTICATED, $principal->getType());
$this->assertNull($principal->getHref());
$principal = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::HREF,'admin');
$this->assertEquals(Sabre_DAVACL_Property_Principal::HREF, $principal->getType());
$this->assertEquals('admin',$principal->getHref());
}
/**
* @depends testSimple
* @expectedException Sabre_DAV_Exception
*/
function testNoHref() {
$principal = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::HREF);
}
/**
* @depends testSimple
*/
function testSerializeUnAuthenticated() {
$prin = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::UNAUTHENTICATED);
$doc = new DOMDocument();
$root = $doc->createElement('d:principal');
$root->setAttribute('xmlns:d','DAV:');
$doc->appendChild($root);
$objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir'));
$server = new Sabre_DAV_Server($objectTree);
$prin->serialize($server, $root);
$xml = $doc->saveXML();
$this->assertEquals(
'
' .
'' .
'
', $xml);
}
/**
* @depends testSerializeUnAuthenticated
*/
function testSerializeAuthenticated() {
$prin = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::AUTHENTICATED);
$doc = new DOMDocument();
$root = $doc->createElement('d:principal');
$root->setAttribute('xmlns:d','DAV:');
$doc->appendChild($root);
$objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir'));
$server = new Sabre_DAV_Server($objectTree);
$prin->serialize($server, $root);
$xml = $doc->saveXML();
$this->assertEquals(
'
' .
'' .
'
', $xml);
}
/**
* @depends testSerializeUnAuthenticated
*/
function testSerializeHref() {
$prin = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::HREF,'principals/admin');
$doc = new DOMDocument();
$root = $doc->createElement('d:principal');
$root->setAttribute('xmlns:d','DAV:');
$doc->appendChild($root);
$objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir'));
$server = new Sabre_DAV_Server($objectTree);
$prin->serialize($server, $root);
$xml = $doc->saveXML();
$this->assertEquals(
'
' .
'/principals/admin' .
'
', $xml);
}
function testUnserializeHref() {
$xml = '
' .
'/principals/admin' .
'';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$principal = Sabre_DAVACL_Property_Principal::unserialize($dom->firstChild);
$this->assertEquals(Sabre_DAVACL_Property_Principal::HREF, $principal->getType());
$this->assertEquals('/principals/admin', $principal->getHref());
}
function testUnserializeAuthenticated() {
$xml = '
' .
' ' .
'';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$principal = Sabre_DAVACL_Property_Principal::unserialize($dom->firstChild);
$this->assertEquals(Sabre_DAVACL_Property_Principal::AUTHENTICATED, $principal->getType());
}
function testUnserializeUnauthenticated() {
$xml = '
' .
' ' .
'';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$principal = Sabre_DAVACL_Property_Principal::unserialize($dom->firstChild);
$this->assertEquals(Sabre_DAVACL_Property_Principal::UNAUTHENTICATED, $principal->getType());
}
/**
* @expectedException Sabre_DAV_Exception_BadRequest
*/
function testUnserializeUnknown() {
$xml = '
' .
' ' .
'';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
Sabre_DAVACL_Property_Principal::unserialize($dom->firstChild);
}
}