Functional test and AuthManager


I am new to testing, and I am trying to fake the AuthManager module, for testing logged users to access different actions. I generated users, and I made a fixture for it, but I really cant find anything about faking AuthManager.

I am using RBAC authorization (from DB), and when I populate the auth_assignment table manually, it works as I expected, but it is really inconvinient of use, I rather use fixture for it.

Anybody can help to solve this issue, or give me a proper article about this? I’ve googled it for hours, but I didnt found anything:(

Thanks in advance.

I simply wrote fixtures manually, not using activefixtures but fixtures. Probably not the best way but it works fine.

I have a fairly fixed set of roles and permissions…

Thanks for your reply. Which model did you use for the fixture? I tried to extend ArrayFixture for auth_assignment table, but it didnt work (maybe I missed something).

I simply set the model name instead of specifying the class.

I will check when I am not on my phone.

But check the code for fixture.

I’ve found a solution. Maybe it will be usefull for someone else too:)

I simply change the config in tests to:

'components' => [


		'authManager' => [

			'class'          => 'yii\rbac\PhpManager',

			'itemFile'       => '@tests/codeception/common/fixtures/rbac/items.php',

			'assignmentFile' => '@tests/codeception/common/fixtures/rbac/assignments.php',

			'ruleFile'       => '@tests/codeception/common/fixtures/rbac/rules.php',




and created the files with the following content:



return [

    'user' => [

        'type' => 1,


    'admin' => [

        'type' => 1,

        'children' => [







return [

    1 => [






return [];