Yii Framework Forum: functional test for login action - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

functional test for login action

#1 User is offline   masih fathi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 01-April 17

Posted 01 April 2017 - 11:29 AM

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->amLoggedInAs(1);
    $I->amOnPage('/');
    $I->see('Logout (admin)');
}

login action work with table user:
    
   public static function findIdentity($id) {
        return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]);
   }

0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,184
  • Joined: 17-January 09
  • Location:Russia

Posted 01 April 2017 - 01:05 PM

Please post full error including message, file, line, whole stacktrace. Else it's not possible to guess the reason.
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I can work more on Yii: https://www.patreon.com/samdark
0

#3 User is offline   masih fathi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 01-April 17

Posted 01 April 2017 - 03:00 PM

View Postsamdark, on 01 April 2017 - 01:05 PM, said:

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

0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,184
  • Joined: 17-January 09
  • Location:Russia

Posted 02 April 2017 - 02:51 PM

No idea, sorry.
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I can work more on Yii: https://www.patreon.com/samdark
0

#5 User is offline   masih fathi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 01-April 17

Posted 03 April 2017 - 09:31 AM

View Postsamdark, on 02 April 2017 - 02:51 PM, said:

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.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users