mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-12 03:30:12 +08:00
Add test for #18031 - User login events not triggered when using \yii\web\HttpBasicAuth login (#18193)
This commit is contained in:
committed by
GitHub
parent
c47aed2a7c
commit
d0a1a0486d
@@ -10,6 +10,8 @@ namespace yiiunit\framework\filters\auth;
|
|||||||
use Yii;
|
use Yii;
|
||||||
use yii\filters\auth\HttpBasicAuth;
|
use yii\filters\auth\HttpBasicAuth;
|
||||||
use yiiunit\framework\filters\stubs\UserIdentity;
|
use yiiunit\framework\filters\stubs\UserIdentity;
|
||||||
|
use yii\base\Event;
|
||||||
|
use yii\web\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group filters
|
* @group filters
|
||||||
@@ -122,4 +124,20 @@ class BasicAuthTest extends AuthTest
|
|||||||
['yii\filters\auth\HttpBasicAuth'],
|
['yii\filters\auth\HttpBasicAuth'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider tokenProvider
|
||||||
|
* @param string|null $token
|
||||||
|
* @param string|null $login
|
||||||
|
*/
|
||||||
|
public function testAfterLoginEventIsTriggered18031($token, $login)
|
||||||
|
{
|
||||||
|
$triggered = false;
|
||||||
|
Event::on('\yii\web\User', User::EVENT_AFTER_LOGIN, function ($event) use (&$triggered) {
|
||||||
|
$triggered = true;
|
||||||
|
$this->assertTrue($triggered);
|
||||||
|
});
|
||||||
|
$this->testHttpBasicAuthCustom($token, $login);
|
||||||
|
Event::off('\yii\web\User', User::EVENT_AFTER_LOGIN); // required because this method runs in foreach loop. See @dataProvider tokenProvider
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user