示例#1
0
 /**
  * Test if the permission index is being set correctly.
  */
 public function test_permission_index()
 {
     Permission::index();
     $index = Permission::getIndex();
     // Index there and is the right type?
     $this->assertInstanceOf('Birdmin\\Collections\\PermissionCollection', $index);
     $this->assertGreaterThan(0, $index->count());
     // Basic permission exists?
     $this->assertInstanceOf('Birdmin\\Permission', $index->lookup('view', 'Birdmin\\Page'));
     // Test the right permission being returned.
     $permission = $index->lookup('view', 'Birdmin\\Page');
     $this->assertEquals('view', $permission->ability);
     $this->assertEquals('Birdmin\\Page', $permission->object);
     // Non-existent permission returning null with bogus ability?
     $this->assertNull($index->lookup('wrong', 'Birdmin\\Page'));
     // Non-existent permission returning null with bogus model?
     $this->assertNull($index->lookup('view', 'Wrong'));
 }