Z
Z
zbender2014-01-22 08:43:16
Yii
zbender, 2014-01-22 08:43:16

Yii::app()->user->isGuest when testing with phpunit

In the tests, Yii::app()->user->login, Yii::app()->user->logout are executed several times in order to test under different users.
But after the second login, the value of Yii::app()->user->isGuest does not change (constantly false)
. if you run the following code:

echo (int)Yii::app()->user->isGuest;
Yii::app()->user->login;
echo (int)Yii::app()->user->isGuest;
Yii::app()->user->logout
echo (int)Yii::app()->user->isGuest;
... итд

Then as a result we get: 1 0 1 0 0 0 0 0 0 0 0 0
Because of what can the value of isGuest not change?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vit, 2014-01-22
@zbender

> the user component is inherited from EMongoDocument.
This is somewhat strange.
Then see how you have implemented the getIsGuest, login and logout functions in this component

D
Dialog, 2014-01-22
@Dialog

Yii::app()->user is a session, sessions in cli don't work very well, that is, the first time the variable will work, the rest of the time it won't work. Authorization is an acceptance test.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question