Skip to content

Commit

Permalink
A few more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rogov Viktor committed Aug 19, 2014
1 parent 32d8994 commit ff09da5
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Tests/InMemoryRbacTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit ff09da5

Please sign in to comment.