|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace yii2mod\rbac\tests\models; |
| 4 | + |
| 5 | +use yii2mod\rbac\models\RouteModel; |
| 6 | +use yii2mod\rbac\tests\TestCase; |
| 7 | + |
| 8 | +/** |
| 9 | + * Class RouteTest |
| 10 | + * |
| 11 | + * @package yii2mod\rbac\tests\models |
| 12 | + */ |
| 13 | +class RouteTest extends TestCase |
| 14 | +{ |
| 15 | + public function testGetAppRoutes() |
| 16 | + { |
| 17 | + $model = new RouteModel(); |
| 18 | + $routes = $model->getAppRoutes(); |
| 19 | + |
| 20 | + $this->assertCount(34, $routes); |
| 21 | + $this->assertContains('/rbac/assignment/index', $routes); |
| 22 | + $this->assertContains('/rbac/permission/index', $routes); |
| 23 | + $this->assertContains('/rbac/role/index', $routes); |
| 24 | + $this->assertContains('/rbac/route/index', $routes); |
| 25 | + $this->assertContains('/rbac/rule/index', $routes); |
| 26 | + $this->assertContains('/rbac/*', $routes); |
| 27 | + $this->assertContains('/*', $routes); |
| 28 | + } |
| 29 | + |
| 30 | + public function testGetAvailableAndAssignedRoutes() |
| 31 | + { |
| 32 | + $model = new RouteModel(); |
| 33 | + $routes = $model->getAvailableAndAssignedRoutes(); |
| 34 | + |
| 35 | + $this->assertArrayHasKey('available', $routes); |
| 36 | + $this->assertArrayHasKey('assigned', $routes); |
| 37 | + $this->assertCount(34, $routes['available']); |
| 38 | + $this->assertCount(0, $routes['assigned']); |
| 39 | + } |
| 40 | +} |
0 commit comments