Skip to content

Commit b5ea835

Browse files
author
igor
committed
update tests for BizRuleModel
1 parent efb8445 commit b5ea835

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

tests/TestCase.php

+8
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ protected function mockApplication($config = [], $appClass = '\yii\web\Applicati
5555
'hostInfo' => 'http://domain.com',
5656
'scriptUrl' => 'index.php'
5757
],
58+
'i18n' => [
59+
'translations' => [
60+
'yii2mod.rbac' => [
61+
'class' => 'yii\i18n\PhpMessageSource',
62+
'basePath' => '@yii2mod/rbac/messages',
63+
]
64+
]
65+
]
5866
],
5967
], $config));
6068
}

tests/models/BizRuleTest.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,18 @@ public function testCreateRule()
3232
* @depends testCreateRule
3333
* @param $rule
3434
*/
35-
public function testRemoveRole($rule)
35+
public function testRemoveRule($rule)
3636
{
3737
$this->assertTrue(Yii::$app->authManager->remove($rule));
3838
}
39+
40+
public function testTryToCreateRuleWithInvalidClassName()
41+
{
42+
$model = new BizRuleModel;
43+
$model->name = 'guest';
44+
$model->className = 'invalid className';
45+
46+
$this->assertFalse($model->save());
47+
$this->assertArrayHasKey('className', $model->getErrors());
48+
}
3949
}

0 commit comments

Comments
 (0)