mirror of
https://github.com/elyby/accounts.git
synced 2024-12-27 23:50:19 +05:30
Исправлен NPE в AccountOwner
This commit is contained in:
parent
bd3e8cf2bd
commit
3138a74a7f
@ -30,7 +30,10 @@ class AccountOwner extends Rule {
|
||||
}
|
||||
|
||||
$identity = Yii::$app->user->findIdentityByAccessToken($accessToken);
|
||||
/** @noinspection NullPointerExceptionInspection это исключено, т.к. уже сработал authManager */
|
||||
if ($identity === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$account = $identity->getAccount();
|
||||
if ($account === null) {
|
||||
return false;
|
||||
|
@ -12,6 +12,16 @@ use const common\LATEST_RULES_VERSION;
|
||||
|
||||
class AccountOwnerTest extends TestCase {
|
||||
|
||||
public function testIdentityIsNull() {
|
||||
$component = mock(Component::class . '[findIdentityByAccessToken]', [['secret' => 'secret']]);
|
||||
$component->shouldDeferMissing();
|
||||
$component->shouldReceive('findIdentityByAccessToken')->andReturn(null);
|
||||
|
||||
Yii::$app->set('user', $component);
|
||||
|
||||
$this->assertFalse((new AccountOwner())->execute('some token', new Item(), ['accountId' => 123]));
|
||||
}
|
||||
|
||||
public function testExecute() {
|
||||
$rule = new AccountOwner();
|
||||
$item = new Item();
|
||||
|
Loading…
Reference in New Issue
Block a user