PhpManagerTest.php 659 Bytes
Newer Older
Alexander Kochetov committed
1 2 3 4
<?php

namespace yiiunit\framework\rbac;

Alexander Kochetov committed
5
use Yii;
Alexander Kochetov committed
6 7
use yii\rbac\PhpManager;

8 9 10
/**
 * @group rbac
 */
Alexander Makarov committed
11
class PhpManagerTest extends ManagerTestCase
Alexander Kochetov committed
12
{
Carsten Brandt committed
13
	protected function setUp()
Alexander Kochetov committed
14
	{
Carsten Brandt committed
15 16
		parent::setUp();
		$this->mockApplication();
Alexander Kochetov committed
17
		$authFile = Yii::$app->getRuntimePath() . '/rbac.php';
Alexander Kochetov committed
18 19 20 21 22 23 24
		@unlink($authFile);
		$this->auth = new PhpManager;
		$this->auth->authFile = $authFile;
		$this->auth->init();
		$this->prepareData();
	}

Carsten Brandt committed
25
	protected function tearDown()
Alexander Kochetov committed
26
	{
Carsten Brandt committed
27
		parent::tearDown();
Alexander Kochetov committed
28 29 30 31 32 33 34 35 36 37 38
		@unlink($this->auth->authFile);
	}

	public function testSaveLoad()
	{
		$this->auth->save();
		$this->auth->clearAll();
		$this->auth->load();
		$this->testCheckAccess();
	}
}