Esempio n. 1
0
 public function testCreateItem()
 {
     $type = Item::TYPE_TASK;
     $name = 'editUser';
     $description = 'edit a user';
     $ruleName = 'isAuthor';
     $data = [1, 2, 3];
     $item = $this->auth->createItem($name, $type, $description, $ruleName, $data);
     $this->assertTrue($item instanceof Item);
     $this->assertEquals($item->type, $type);
     $this->assertEquals($item->name, $name);
     $this->assertEquals($item->description, $description);
     $this->assertEquals($item->ruleName, $ruleName);
     $this->assertEquals($item->data, $data);
     // test shortcut
     $name2 = 'createUser';
     $item2 = $this->auth->createRole($name2, $description, $ruleName, $data);
     $this->assertEquals($item2->type, Item::TYPE_ROLE);
     // test adding an item with the same name
     $this->setExpectedException('\\yii\\base\\Exception');
     $this->auth->createItem($name, $type, $description, $ruleName, $data);
 }