Total Complexity | 4 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class TestCase extends \PHPUnit\Framework\TestCase |
||
10 | { |
||
11 | /** |
||
12 | * getMockAsArray |
||
13 | * |
||
14 | * @param string $fileName |
||
15 | * @return array |
||
16 | * @author Casper Rasmussen <[email protected]> |
||
17 | */ |
||
18 | protected function getMockAsArray(string $fileName): array |
||
19 | { |
||
20 | $content = file_get_contents(getcwd() . '/tests/mocks/' . $fileName); |
||
21 | |||
22 | return json_decode($content, true); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * getClientWithMockedGet |
||
27 | * |
||
28 | * @param string $filename |
||
29 | * @return \GuzzleHttp\Client |
||
30 | * @author Casper Rasmussen <[email protected]> |
||
31 | */ |
||
32 | protected function getClientWithMockedGet(string $filename): Client |
||
33 | { |
||
34 | $response = new Response(200, ['Content-Type' => 'application/json'], |
||
35 | $this->getMockAsString($filename)); |
||
36 | |||
37 | $guzzle = \Mockery::mock(\GuzzleHttp\Client::class); |
||
38 | $guzzle->shouldReceive('get')->once()->andReturn($response); |
||
39 | |||
40 | return $guzzle; |
||
|
|||
41 | } |
||
42 | |||
43 | /** |
||
44 | * getMockAsString |
||
45 | * |
||
46 | * @param string $fileName |
||
47 | * @return string |
||
48 | * @author Casper Rasmussen <[email protected]> |
||
49 | */ |
||
50 | protected function getMockAsString(string $fileName): string |
||
51 | { |
||
52 | return file_get_contents(getcwd() . '/tests/mocks/' . $fileName); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * getConfig |
||
57 | * |
||
58 | * @return \NStack\Config |
||
59 | * @author Casper Rasmussen <[email protected]> |
||
60 | */ |
||
61 | public function getConfig(): Config |
||
64 | } |
||
65 | } |
||
66 |