functional test for login action

i write a simple functional test for login action but i get the error:

[Error] Call to a member function get() on null

i actually login to the app by the login form but when i run tests it gets error.


public function internalLoginById(\FunctionalTester $I) {



    $I->see('Logout (admin)');


login action work with table user:


   public static function findIdentity($id) {

        return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]);


Please post full error including message, file, line, whole stacktrace. Else it’s not possible to guess the reason.

user table implement Identity Interface and properly work in actual scenario but in test scenario i got the below error

the full error in terminal is :

LoginFormCest: Internal login by id

 Test  tests/functional/LoginFormCest.php:internalLoginById


  [Error] Call to a member function get() on null  


Scenario Steps:

 3. $I->amOnPage("/") at tests/functional/LoginFormCest.php:16

 2. $I->amLoggedInAs(1) at tests/functional/LoginFormCest.php:15

 1. $I->amOnPage({"0":"site\/login","language":"en"}) at tests/functional/LoginFormCest.php:6

#1  /var/www/html/basic/vendor/yiisoft/yii2/base/Widget.php:139

#2  /var/www/html/basic/views/site/index.php:108

#3  /var/www/html/basic/vendor/yiisoft/yii2/base/View.php:328

#4  /var/www/html/basic/vendor/yiisoft/yii2/base/View.php:250

#5  /var/www/html/basic/vendor/yiisoft/yii2/base/View.php:152

#6  /var/www/html/basic/vendor/yiisoft/yii2/base/Controller.php:381

#7  /var/www/html/basic/controllers/SiteController.php:81

#8  app\controllers\SiteController->actionIndex

#9  /var/www/html/basic/vendor/yiisoft/yii2/base/InlineAction.php:57

#10 /var/www/html/basic/vendor/yiisoft/yii2/base/Controller.php:156

No idea, sorry.

thanks to the Alexander Makarov for checking this issue. finally i found the problem, the problem was in my config/test.php and configuration has the problem.