|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: arthur |
|
5
|
|
|
* Date: 09.10.18 |
|
6
|
|
|
* Time: 21:56. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Foundation\Abstracts\Tests; |
|
10
|
|
|
|
|
11
|
|
|
use Auth0\Login\Contract\Auth0UserRepository; |
|
|
|
|
|
|
12
|
|
|
use Illuminate\Contracts\Auth\Authenticatable; |
|
13
|
|
|
use Modules\Auth0\Services\Auth0Service; |
|
14
|
|
|
use Modules\User\Entities\User; |
|
15
|
|
|
|
|
16
|
|
|
abstract class HttpTest extends \Foundation\Abstracts\Tests\TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var Auth0Service |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $service; |
|
22
|
|
|
|
|
23
|
10 |
|
public function setUp() |
|
24
|
|
|
{ |
|
25
|
10 |
|
parent::setUp(); |
|
26
|
10 |
|
$this->service = $this->app->make(Auth0UserRepository::class); |
|
27
|
10 |
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @return User | Authenticatable |
|
31
|
|
|
*/ |
|
32
|
7 |
|
protected function getHttpUser() |
|
33
|
|
|
{ |
|
34
|
7 |
|
return $this->service->getPredefinedUser(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
2 |
|
protected function decodeHttpContent($content, $unwrap = true) |
|
38
|
|
|
{ |
|
39
|
2 |
|
if ($unwrap) { |
|
40
|
2 |
|
return json_decode($content, true)['data']; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return json_decode($content, true); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
6 |
|
protected function http(string $method, string $route, array $payload = []) |
|
47
|
|
|
{ |
|
48
|
6 |
|
return $this->sendRequest($method, $route, $payload, true); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
7 |
|
private function sendRequest(string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
52
|
|
|
{ |
|
53
|
7 |
|
return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
|
54
|
6 |
|
'Authorization' => 'Bearer '.$this->service->getPredefinedUserTokenData()->id_token, |
|
55
|
7 |
|
] : []); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
protected function sendRequestWithToken($token, string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
|
61
|
|
|
'Authorization' => 'Bearer '.$token, |
|
62
|
|
|
] : []); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
1 |
|
protected function httpNoAuth(string $method, string $route, array $payload = []) |
|
66
|
|
|
{ |
|
67
|
1 |
|
return $this->sendRequest($method, $route, $payload, false); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths