1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File: AuthorizationTest.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\Exception\Authorization\FreshMailAuthorizationException; |
12
|
|
|
use MSlwk\FreshMail\Exception\Connection\FreshMailConnectionException; |
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
use MSlwk\FreshMail\Error\ErrorHandler; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class AuthorizationTest |
18
|
|
|
* |
19
|
|
|
* @package MSlwk\FreshMail\Test\Base |
20
|
|
|
*/ |
21
|
|
|
class AuthorizationTest extends TestCase |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @param $sendRequestReturnValue |
25
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject |
|
|
|
|
26
|
|
|
*/ |
27
|
|
|
private function getPingHandlerMock($sendRequestReturnValue) |
28
|
|
|
{ |
29
|
|
|
$pingHandler = $this->getMockBuilder('\MSlwk\FreshMail\Handler\Ping\PingHandler') |
|
|
|
|
30
|
|
|
->setConstructorArgs([new ErrorHandler(), '', '']) |
31
|
|
|
->setMethods(['sendRequest']) |
32
|
|
|
->getMock(); |
33
|
|
|
|
34
|
|
|
$pingHandler->expects($this->once()) |
35
|
|
|
->method('sendRequest') |
36
|
|
|
->with('', '') |
37
|
|
|
->will($this->returnValue($sendRequestReturnValue)); |
38
|
|
|
|
39
|
|
|
return $pingHandler; |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testNoAuthorization() |
43
|
|
|
{ |
44
|
|
|
$pingHandler = $this->getPingHandlerMock( |
45
|
|
|
'{"errors":[{ "message":"No authorization", "code":"1000" }], "status":"errors"}' |
46
|
|
|
); |
47
|
|
|
$this->expectException(FreshMailAuthorizationException::class); |
48
|
|
|
$pingHandler->ping(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testActionNotFound() |
52
|
|
|
{ |
53
|
|
|
$pingHandler = $this->getPingHandlerMock( |
54
|
|
|
'{"errors":[{ "message":"Method not found", "code":"1001" }], "status":"errors"}' |
55
|
|
|
); |
56
|
|
|
$this->expectException(FreshMailAuthorizationException::class); |
57
|
|
|
$pingHandler->ping(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testUnsupportedProtocol() |
61
|
|
|
{ |
62
|
|
|
$pingHandler = $this->getPingHandlerMock( |
63
|
|
|
'{"errors":[{ "message":"Protocol not supported", "code":"1002" }], "status":"errors"}' |
64
|
|
|
); |
65
|
|
|
$this->expectException(FreshMailAuthorizationException::class); |
66
|
|
|
$pingHandler->ping(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function testUnsupportedHttpMethod() |
70
|
|
|
{ |
71
|
|
|
$pingHandler = $this->getPingHandlerMock( |
72
|
|
|
'{"errors":[{ "message":"Unsupported request type", "code":"1003" }], "status":"errors"}' |
73
|
|
|
); |
74
|
|
|
$this->expectException(FreshMailAuthorizationException::class); |
75
|
|
|
$pingHandler->ping(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function testAccessDenied() |
79
|
|
|
{ |
80
|
|
|
$pingHandler = $this->getPingHandlerMock( |
81
|
|
|
'{"errors":[{ "message":"Access denied", "code":"1004" }], "status":"errors"}' |
82
|
|
|
); |
83
|
|
|
$this->expectException(FreshMailAuthorizationException::class); |
84
|
|
|
$pingHandler->ping(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function testApiFailedToRespond() |
88
|
|
|
{ |
89
|
|
|
$pingHandler = $this->getPingHandlerMock(''); |
90
|
|
|
$this->expectException(FreshMailConnectionException::class); |
91
|
|
|
$pingHandler->ping(); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
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