Fix some tests

This commit is contained in:
ErickSkrauch
2019-08-01 19:58:18 +03:00
parent 45c2ed601d
commit 6bd054e743
7 changed files with 17 additions and 39 deletions

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace common\tests\unit\rbac\rules;
use api\components\User\Component;
@@ -13,12 +15,8 @@ use const common\LATEST_RULES_VERSION;
class AccountOwnerTest extends TestCase {
public function testIdentityIsNull() {
$component = mock(Component::class . '[findIdentityByAccessToken]', [[
'secret' => 'secret',
'publicKeyPath' => 'data/certs/public.crt',
'privateKeyPath' => 'data/certs/private.key',
]]);
$component->shouldDeferMissing();
$component = mock(Component::class . '[findIdentityByAccessToken]');
$component->makePartial();
$component->shouldReceive('findIdentityByAccessToken')->andReturn(null);
Yii::$app->set('user', $component);
@@ -38,12 +36,8 @@ class AccountOwnerTest extends TestCase {
$identity = mock(IdentityInterface::class);
$identity->shouldReceive('getAccount')->andReturn($account);
$component = mock(Component::class . '[findIdentityByAccessToken]', [[
'secret' => 'secret',
'publicKeyPath' => 'data/certs/public.crt',
'privateKeyPath' => 'data/certs/private.key',
]]);
$component->shouldDeferMissing();
$component = mock(Component::class . '[findIdentityByAccessToken]');
$component->makePartial();
$component->shouldReceive('findIdentityByAccessToken')->withArgs(['token'])->andReturn($identity);
Yii::$app->set('user', $component);

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace common\tests\unit\rbac\rules;
use api\components\User\Component;
@@ -34,12 +36,8 @@ class OauthClientOwnerTest extends TestCase {
$identity->shouldReceive('getAccount')->andReturn($account);
/** @var Component|\Mockery\MockInterface $component */
$component = mock(Component::class . '[findIdentityByAccessToken]', [[
'secret' => 'secret',
'publicKeyPath' => 'data/certs/public.crt',
'privateKeyPath' => 'data/certs/private.key',
]]);
$component->shouldDeferMissing();
$component = mock(Component::class . '[findIdentityByAccessToken]');
$component->makePartial();
$component->shouldReceive('findIdentityByAccessToken')->withArgs(['token'])->andReturn($identity);
Yii::$app->set('user', $component);