AuthorizedHttpTest::httpNoAuth()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 4
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 05.03.19
6
 * Time: 11:54.
7
 */
8
9
namespace Modules\Auth0\Abstracts;
10
11
use Foundation\Abstracts\Tests\HttpTest;
12
use Foundation\Abstracts\Tests\TestResponse;
13
use Modules\Auth0\Traits\Auth0TestUser;
14
use Modules\Authorization\Traits\UserTestRoles;
15
use Modules\User\Entities\User;
16
17
abstract class AuthorizedHttpTest extends HttpTest
18
{
19
    use Auth0TestUser, UserTestRoles;
0 ignored issues
show
Bug introduced by
The trait Modules\Auth0\Traits\Auth0TestUser requires the property $id_token which is not provided by Modules\Auth0\Abstracts\AuthorizedHttpTest.
Loading history...
Bug introduced by
The trait Modules\Authorization\Traits\UserTestRoles requires the property $roles which is not provided by Modules\Auth0\Abstracts\AuthorizedHttpTest.
Loading history...
20
21
    protected function http(string $method, string $route, array $payload = [], array $headers = []): TestResponse
22
    {
23
        $headers['Authorization'] = 'Bearer '.$this->getUserAuth0Token()->id_token;
24
25
        return parent::http($method, $route, $payload, $headers);
26
    }
27
28
    protected function httpNoAuth(string $method, string $route, array $payload = [], array $headers = []): TestResponse
29
    {
30
        return parent::http($method, $route, $payload, $headers);
31
    }
32
33
    protected function actingUser()
34
    {
35
        return $this->getTestUser();
36
    }
37
38
    public function actingAs($user, $driver = null)
39
    {
40
        if (! $user->is($this->getTestUser())) {
41
            throw new \Foundation\Exceptions\Exception('cannot set another user for authorized http tests. Sync other roles/permissions instead.');
42
        }
43
        parent::actingAs($user, $driver);
44
    }
45
}
46