added unit test for #4489

This commit is contained in:
Carsten Brandt
2014-07-28 23:48:10 +02:00
parent a7044c835b
commit 9e62d5589a
2 changed files with 22 additions and 1 deletions

View File

@ -4,6 +4,7 @@ namespace yiiunit\framework\rbac;
use yii\rbac\Item;
use yii\rbac\Permission;
use yii\rbac\PhpManager;
use yii\rbac\Role;
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('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)));
}
}

View File

@ -76,4 +76,4 @@ class PhpManagerTest extends ManagerTestCase
$this->assertEquals($assignments, $this->auth->assignments);
$this->assertEquals($rules, $this->auth->rules);
}
}
}