mirror of
https://github.com/elyby/accounts.git
synced 2024-11-27 01:02:06 +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);
|
$identity = Yii::$app->user->findIdentityByAccessToken($accessToken);
|
||||||
/** @noinspection NullPointerExceptionInspection это исключено, т.к. уже сработал authManager */
|
if ($identity === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$account = $identity->getAccount();
|
$account = $identity->getAccount();
|
||||||
if ($account === null) {
|
if ($account === null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -12,6 +12,16 @@ use const common\LATEST_RULES_VERSION;
|
|||||||
|
|
||||||
class AccountOwnerTest extends TestCase {
|
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() {
|
public function testExecute() {
|
||||||
$rule = new AccountOwner();
|
$rule = new AccountOwner();
|
||||||
$item = new Item();
|
$item = new Item();
|
||||||
|
Loading…
Reference in New Issue
Block a user