public function testDoesAllow() { $this->calendar->setCruds(Permissions::CREATE); $this->assertTrue($this->calendar->doesAllow(Permissions::CREATE)); $this->assertFalse($this->calendar->doesAllow(Permissions::READ)); $this->assertFalse($this->calendar->doesAllow(Permissions::UPDATE)); $this->assertFalse($this->calendar->doesAllow(Permissions::DELETE)); $this->assertFalse($this->calendar->doesAllow(Permissions::SHARE)); $this->calendar->setCruds(Permissions::READ); $this->assertFalse($this->calendar->doesAllow(Permissions::CREATE)); $this->assertTrue($this->calendar->doesAllow(Permissions::READ)); $this->assertFalse($this->calendar->doesAllow(Permissions::UPDATE)); $this->assertFalse($this->calendar->doesAllow(Permissions::DELETE)); $this->assertFalse($this->calendar->doesAllow(Permissions::SHARE)); $this->calendar->setCruds(Permissions::UPDATE); $this->assertFalse($this->calendar->doesAllow(Permissions::CREATE)); $this->assertFalse($this->calendar->doesAllow(Permissions::READ)); $this->assertTrue($this->calendar->doesAllow(Permissions::UPDATE)); $this->assertFalse($this->calendar->doesAllow(Permissions::DELETE)); $this->assertFalse($this->calendar->doesAllow(Permissions::SHARE)); $this->calendar->setCruds(Permissions::DELETE); $this->assertFalse($this->calendar->doesAllow(Permissions::CREATE)); $this->assertFalse($this->calendar->doesAllow(Permissions::READ)); $this->assertFalse($this->calendar->doesAllow(Permissions::UPDATE)); $this->assertTrue($this->calendar->doesAllow(Permissions::DELETE)); $this->assertFalse($this->calendar->doesAllow(Permissions::SHARE)); $this->calendar->setCruds(Permissions::SHARE); $this->assertFalse($this->calendar->doesAllow(Permissions::CREATE)); $this->assertFalse($this->calendar->doesAllow(Permissions::READ)); $this->assertFalse($this->calendar->doesAllow(Permissions::UPDATE)); $this->assertFalse($this->calendar->doesAllow(Permissions::DELETE)); $this->assertTrue($this->calendar->doesAllow(Permissions::SHARE)); $this->calendar->setCruds(Permissions::ALL); $this->assertTrue($this->calendar->doesAllow(Permissions::CREATE)); $this->assertTrue($this->calendar->doesAllow(Permissions::READ)); $this->assertTrue($this->calendar->doesAllow(Permissions::UPDATE)); $this->assertTrue($this->calendar->doesAllow(Permissions::DELETE)); $this->assertTrue($this->calendar->doesAllow(Permissions::SHARE)); $this->calendar->setCruds(Permissions::ALL_CALENDAR); $this->assertTrue($this->calendar->doesAllow(Permissions::CREATE)); $this->assertTrue($this->calendar->doesAllow(Permissions::READ)); $this->assertTrue($this->calendar->doesAllow(Permissions::UPDATE)); $this->assertTrue($this->calendar->doesAllow(Permissions::DELETE)); $this->assertTrue($this->calendar->doesAllow(Permissions::SHARE)); $this->calendar->setCruds(Permissions::ALL_OBJECT); $this->assertFalse($this->calendar->doesAllow(Permissions::CREATE)); $this->assertTrue($this->calendar->doesAllow(Permissions::READ)); $this->assertTrue($this->calendar->doesAllow(Permissions::UPDATE)); $this->assertTrue($this->calendar->doesAllow(Permissions::DELETE)); $this->assertTrue($this->calendar->doesAllow(Permissions::SHARE)); }
/** * @param integer $action * @throws Exception */ protected function checkCalendarSupports($action) { if (!$this->calendar->doesAllow($action)) { switch ($action) { case Permissions::CREATE: throw new Exception('Calendar does not allow creating objects'); break; case Permissions::UPDATE: throw new Exception('Calendar does not allow updating objects'); break; case Permissions::DELETE: throw new Exception('Calendar does not allow deleting objects'); break; default: throw new Exception('Calendar does not support wanted action'); break; } } }