1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\DAVACL; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehleruse Sabre\DAV; 6*a1a3b679SAndreas Boehleruse Sabre\HTTP; 7*a1a3b679SAndreas Boehler 8*a1a3b679SAndreas Boehler 9*a1a3b679SAndreas Boehlerclass PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { 10*a1a3b679SAndreas Boehler 11*a1a3b679SAndreas Boehler public function testBasic() { 12*a1a3b679SAndreas Boehler 13*a1a3b679SAndreas Boehler $backend = new PrincipalBackend\Mock(); 14*a1a3b679SAndreas Boehler $pc = new PrincipalCollection($backend); 15*a1a3b679SAndreas Boehler $this->assertTrue($pc instanceof PrincipalCollection); 16*a1a3b679SAndreas Boehler 17*a1a3b679SAndreas Boehler $this->assertEquals('principals',$pc->getName()); 18*a1a3b679SAndreas Boehler 19*a1a3b679SAndreas Boehler } 20*a1a3b679SAndreas Boehler 21*a1a3b679SAndreas Boehler /** 22*a1a3b679SAndreas Boehler * @depends testBasic 23*a1a3b679SAndreas Boehler */ 24*a1a3b679SAndreas Boehler public function testGetChildren() { 25*a1a3b679SAndreas Boehler 26*a1a3b679SAndreas Boehler $backend = new PrincipalBackend\Mock(); 27*a1a3b679SAndreas Boehler $pc = new PrincipalCollection($backend); 28*a1a3b679SAndreas Boehler 29*a1a3b679SAndreas Boehler $children = $pc->getChildren(); 30*a1a3b679SAndreas Boehler $this->assertTrue(is_array($children)); 31*a1a3b679SAndreas Boehler 32*a1a3b679SAndreas Boehler foreach($children as $child) { 33*a1a3b679SAndreas Boehler $this->assertTrue($child instanceof IPrincipal); 34*a1a3b679SAndreas Boehler } 35*a1a3b679SAndreas Boehler 36*a1a3b679SAndreas Boehler } 37*a1a3b679SAndreas Boehler 38*a1a3b679SAndreas Boehler /** 39*a1a3b679SAndreas Boehler * @depends testBasic 40*a1a3b679SAndreas Boehler * @expectedException Sabre\DAV\Exception\MethodNotAllowed 41*a1a3b679SAndreas Boehler */ 42*a1a3b679SAndreas Boehler public function testGetChildrenDisable() { 43*a1a3b679SAndreas Boehler 44*a1a3b679SAndreas Boehler $backend = new PrincipalBackend\Mock(); 45*a1a3b679SAndreas Boehler $pc = new PrincipalCollection($backend); 46*a1a3b679SAndreas Boehler $pc->disableListing = true; 47*a1a3b679SAndreas Boehler 48*a1a3b679SAndreas Boehler $children = $pc->getChildren(); 49*a1a3b679SAndreas Boehler 50*a1a3b679SAndreas Boehler } 51*a1a3b679SAndreas Boehler 52*a1a3b679SAndreas Boehler public function testFindByUri() { 53*a1a3b679SAndreas Boehler 54*a1a3b679SAndreas Boehler $backend = new PrincipalBackend\Mock(); 55*a1a3b679SAndreas Boehler $pc = new PrincipalCollection($backend); 56*a1a3b679SAndreas Boehler $this->assertEquals('principals/user1', $pc->findByUri('mailto:user1.sabredav@sabredav.org')); 57*a1a3b679SAndreas Boehler $this->assertNull($pc->findByUri('mailto:fake.user.sabredav@sabredav.org')); 58*a1a3b679SAndreas Boehler $this->assertNull($pc->findByUri('')); 59*a1a3b679SAndreas Boehler } 60*a1a3b679SAndreas Boehler 61*a1a3b679SAndreas Boehler} 62