diff --git a/Tests/InMemoryRbacTest.php b/Tests/InMemoryRbacTest.php index b2f4184..f7c2776 100644 --- a/Tests/InMemoryRbacTest.php +++ b/Tests/InMemoryRbacTest.php @@ -71,6 +71,21 @@ public function testVisitorCanRead() )); } + public function testVisitorCantEdit() + { + $this->assertFalse($this->rbac->checkPermission( + new User(1), + $this->rbac->loadPermission('edit'), + array('object' => new Post(1)) + )); + + $this->assertFalse($this->rbac->checkPermission( + new User(1), + $this->rbac->loadPermission('edit'), + array('object' => new Post(2)) + )); + } + public function testMemberCanEditOwnPosts() { $this->assertTrue($this->rbac->checkPermission( @@ -86,6 +101,36 @@ public function testMemberCanEditOwnPosts() )); } + public function testMemberCanRead() + { + $this->assertTrue($this->rbac->checkPermission( + new User(2), + $this->rbac->loadPermission('read'), + array('object' => new Post(2)) + )); + + $this->assertTrue($this->rbac->checkPermission( + new User(2), + $this->rbac->loadPermission('read'), + array('object' => new Post(3)) + )); + } + + public function testModeratorCanRead() + { + $this->assertTrue($this->rbac->checkPermission( + new User(3), + $this->rbac->loadPermission('read'), + array('object' => new Post(2)) + )); + + $this->assertTrue($this->rbac->checkPermission( + new User(3), + $this->rbac->loadPermission('read'), + array('object' => new Post(3)) + )); + } + public function testModeratorCanEditAll() { $this->assertTrue($this->rbac->checkPermission(