1 | <?php |
||
2 | /** |
||
3 | * File: AbstractHandlerTest.php |
||
4 | * |
||
5 | * @author Maciej Sławik <[email protected]> |
||
6 | * Github: https://github.com/maciejslawik |
||
7 | */ |
||
8 | |||
9 | namespace MSlwk\FreshMail\Test\Base; |
||
10 | |||
11 | use MSlwk\FreshMail\Error\ErrorHandler; |
||
12 | use PHPUnit\Framework\TestCase; |
||
13 | |||
14 | /** |
||
15 | * Class AbstractHandlerTest |
||
16 | * |
||
17 | * @package MSlwk\FreshMail\Test\Base |
||
18 | */ |
||
19 | class AbstractHandlerTest extends TestCase |
||
20 | { |
||
21 | /** |
||
22 | * @param $apiKey |
||
23 | * @param $apiSecret |
||
24 | * @return \PHPUnit_Framework_MockObject_MockObject |
||
0 ignored issues
–
show
|
|||
25 | */ |
||
26 | protected function getAbstractHandlerMock($apiKey, $apiSecret) |
||
27 | { |
||
28 | return $this->getMockForAbstractClass( |
||
0 ignored issues
–
show
|
|||
29 | '\MSlwk\FreshMail\Handler\AbstractHandler', |
||
30 | [ |
||
31 | new ErrorHandler(), |
||
32 | $apiKey, |
||
33 | $apiSecret |
||
34 | ] |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return array |
||
40 | */ |
||
41 | public function providerTestGenerateGetParametersString() |
||
42 | { |
||
43 | return [ |
||
44 | [['user', '123'], '/user/123'], |
||
45 | [[], ''] |
||
46 | ]; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @return array |
||
51 | */ |
||
52 | public function providerTestGeneratePostParametersString() |
||
53 | { |
||
54 | return [ |
||
55 | [['hash' => '124e12', 'email' => '[email protected]'], '{"hash":"124e12","email":"[email protected]"}'], |
||
56 | [[], ''] |
||
57 | ]; |
||
58 | } |
||
59 | |||
60 | public function testAuthorizationHashGeneration() |
||
61 | { |
||
62 | $handler = $this->getAbstractHandlerMock('qwfgqwgqwfqw2e412421r', 'fqwf214214r12dfqf21f'); |
||
63 | |||
64 | $reflection = new \ReflectionClass(get_class($handler)); |
||
65 | $method = $reflection->getMethod('getAuthorizationHash'); |
||
66 | $method->setAccessible(true); |
||
67 | |||
68 | $generatedHash = $method->invokeArgs($handler, ['/rest/ping', '']); |
||
69 | self::assertEquals('fabe17d9e6096a32b6c57cfcef8af070e007e774', $generatedHash); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @param $parametersArray |
||
74 | * @param $expectedResultString |
||
75 | * |
||
76 | * @dataProvider providerTestGenerateGetParametersString |
||
77 | */ |
||
78 | public function testGenerateGetParametersString($parametersArray, $expectedResultString) |
||
79 | { |
||
80 | $handler = $this->getAbstractHandlerMock('', ''); |
||
81 | |||
82 | $reflection = new \ReflectionClass(get_class($handler)); |
||
83 | $method = $reflection->getMethod('generateGetParamsString'); |
||
84 | $method->setAccessible(true); |
||
85 | |||
86 | $generatedResultString = $method->invokeArgs($handler, [$parametersArray]); |
||
87 | self::assertEquals($expectedResultString, $generatedResultString); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @param $parametersArray |
||
92 | * @param $expectedResultString |
||
93 | * |
||
94 | * @dataProvider providerTestGeneratePostParametersString |
||
95 | */ |
||
96 | public function testGeneratePostParametersString($parametersArray, $expectedResultString) |
||
97 | { |
||
98 | $handler = $this->getAbstractHandlerMock('', ''); |
||
99 | |||
100 | $reflection = new \ReflectionClass(get_class($handler)); |
||
101 | $method = $reflection->getMethod('generatePostParamsString'); |
||
102 | $method->setAccessible(true); |
||
103 | |||
104 | $generatedResultString = $method->invokeArgs($handler, [$parametersArray]); |
||
105 | self::assertEquals($expectedResultString, $generatedResultString); |
||
106 | } |
||
107 | } |
||
108 |
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