|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* File: PingHandlerTest.php |
|
4
|
|
|
* |
|
5
|
|
|
* @author Maciej Sławik <[email protected]> |
|
6
|
|
|
* Github: https://github.com/maciejslawik |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace MSlwk\FreshMail\Test\Ping; |
|
10
|
|
|
|
|
11
|
|
|
use MSlwk\FreshMail\Handler\Ping\PingHandler; |
|
12
|
|
|
use MSlwk\FreshMail\Tests\BaseTest; |
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
14
|
|
|
use MSlwk\FreshMail\Error\ErrorHandler; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class PingTest |
|
18
|
|
|
* |
|
19
|
|
|
* @package MSlwk\FreshMail\Test\Ping |
|
20
|
|
|
*/ |
|
21
|
|
|
class PingHandlerTest extends TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
use BaseTest; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param $sendRequestReturnValue |
|
27
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject |
|
|
|
|
|
|
28
|
|
|
*/ |
|
29
|
|
|
public function getPingHandlerMock($sendRequestReturnValue) |
|
30
|
|
|
{ |
|
31
|
|
|
$pingHandler = $this->getMockBuilder('\MSlwk\FreshMail\Handler\Ping\PingHandler') |
|
|
|
|
|
|
32
|
|
|
->setConstructorArgs([new ErrorHandler(), '', '']) |
|
33
|
|
|
->setMethods(['sendRequest']) |
|
34
|
|
|
->getMock(); |
|
35
|
|
|
|
|
36
|
|
|
$pingHandler->expects($this->once()) |
|
37
|
|
|
->method('sendRequest') |
|
38
|
|
|
->will($this->returnValue($sendRequestReturnValue)); |
|
39
|
|
|
|
|
40
|
|
|
return $pingHandler; |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testReturnPong() |
|
44
|
|
|
{ |
|
45
|
|
|
$pingHandler = $this->getPingHandlerMock('{"status":"OK", "data": "pong"}'); |
|
46
|
|
|
self::assertEquals('pong', $pingHandler->ping()); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function testApiEndpoint() |
|
50
|
|
|
{ |
|
51
|
|
|
$accountCreateHandler = new PingHandler(new ErrorHandler(), '', ''); |
|
52
|
|
|
$expectedApiEndpoint = '/rest/ping'; |
|
53
|
|
|
$returnedApiEndpoint = $this->getApiEndpoint($accountCreateHandler); |
|
54
|
|
|
self::assertEquals($expectedApiEndpoint, $returnedApiEndpoint); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
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