Commit 9e62d558 by Carsten Brandt

added unit test for #4489

parent a7044c83
...@@ -4,6 +4,7 @@ namespace yiiunit\framework\rbac; ...@@ -4,6 +4,7 @@ namespace yiiunit\framework\rbac;
use yii\rbac\Item; use yii\rbac\Item;
use yii\rbac\Permission; use yii\rbac\Permission;
use yii\rbac\PhpManager;
use yii\rbac\Role; use yii\rbac\Role;
use yiiunit\TestCase; use yiiunit\TestCase;
...@@ -268,4 +269,24 @@ abstract class ManagerTestCase extends TestCase ...@@ -268,4 +269,24 @@ abstract class ManagerTestCase extends TestCase
$this->assertContains('reader', $roleNames, 'Roles should contain reader. Currently it has: ' . implode(', ', $roleNames)); $this->assertContains('reader', $roleNames, 'Roles should contain reader. Currently it has: ' . implode(', ', $roleNames));
$this->assertContains('author', $roleNames, 'Roles should contain author. Currently it has: ' . implode(', ', $roleNames)); $this->assertContains('author', $roleNames, 'Roles should contain author. Currently it has: ' . implode(', ', $roleNames));
} }
public function testAssignmentsToIntegerId()
{
$this->prepareData();
$reader = $this->auth->getRole('reader');
$author = $this->auth->getRole('author');
$this->auth->assign($reader, 42);
$this->auth->assign($author, 1337);
$this->auth->assign($reader, 1337);
if ($this->auth instanceof PhpManager) {
$this->auth->save();
}
$this->auth = $this->createManager();
$this->assertEquals(0, count($this->auth->getAssignments(0)));
$this->assertEquals(1, count($this->auth->getAssignments(42)));
$this->assertEquals(2, count($this->auth->getAssignments(1337)));
}
} }
...@@ -76,4 +76,4 @@ class PhpManagerTest extends ManagerTestCase ...@@ -76,4 +76,4 @@ class PhpManagerTest extends ManagerTestCase
$this->assertEquals($assignments, $this->auth->assignments); $this->assertEquals($assignments, $this->auth->assignments);
$this->assertEquals($rules, $this->auth->rules); $this->assertEquals($rules, $this->auth->rules);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment