mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-05 23:47:16 +08:00
added unit test for #4489
This commit is contained in:
@ -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
|
|||||||
$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)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user