|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* File: SubscriberDeleteHandlerTest.php |
|
4
|
|
|
* |
|
5
|
|
|
* @author Maciej Sławik <[email protected]> |
|
6
|
|
|
* Github: https://github.com/maciejslawik |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace MSlwk\FreshMail\Test\Subscriber; |
|
10
|
|
|
|
|
11
|
|
|
use MSlwk\FreshMail\Handler\Subscriber\SubscriberDeleteHandler; |
|
12
|
|
|
use MSlwk\FreshMail\Tests\BaseTest; |
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
14
|
|
|
use MSlwk\FreshMail\Error\ErrorHandler; |
|
15
|
|
|
use MSlwk\FreshMail\Exception\Subscriber\FreshMailSubscriberException; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class SubscriberDeleteHandlerTest |
|
19
|
|
|
* |
|
20
|
|
|
* @package MSlwk\FreshMail\Test\Subscriber |
|
21
|
|
|
*/ |
|
22
|
|
|
class SubscriberDeleteHandlerTest extends TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
use BaseTest; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param $sendRequestReturnValue |
|
28
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject |
|
|
|
|
|
|
29
|
|
|
*/ |
|
30
|
|
|
public function getSubscriberDeleteHandlerMock($sendRequestReturnValue) |
|
31
|
|
|
{ |
|
32
|
|
|
$subscriberDeleteHandler = $this->getMockBuilder('\MSlwk\FreshMail\Handler\Subscriber\SubscriberDeleteHandler') |
|
|
|
|
|
|
33
|
|
|
->setConstructorArgs([new ErrorHandler(), '', '']) |
|
34
|
|
|
->setMethods(['sendRequest']) |
|
35
|
|
|
->getMock(); |
|
36
|
|
|
|
|
37
|
|
|
$subscriberDeleteHandler->expects($this->once()) |
|
38
|
|
|
->method('sendRequest') |
|
39
|
|
|
->will($this->returnValue($sendRequestReturnValue)); |
|
40
|
|
|
|
|
41
|
|
|
return $subscriberDeleteHandler; |
|
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testSubscriberPulledSuccessfully() |
|
45
|
|
|
{ |
|
46
|
|
|
$subscriberDeleteHandler = $this->getSubscriberDeleteHandlerMock('{"status":"OK"}'); |
|
47
|
|
|
self::assertNull($subscriberDeleteHandler->deleteSubscriber('Test', 'Test')); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function testApiEndpoint() |
|
51
|
|
|
{ |
|
52
|
|
|
$subscriberDeleteHandler = new SubscriberDeleteHandler(new ErrorHandler(), '', ''); |
|
53
|
|
|
$expectedApiEndpoint = '/rest/subscriber/delete'; |
|
54
|
|
|
$returnedApiEndpoint = $this->getApiEndpoint($subscriberDeleteHandler); |
|
55
|
|
|
self::assertEquals($expectedApiEndpoint, $returnedApiEndpoint); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function testIncorrectEmail() |
|
59
|
|
|
{ |
|
60
|
|
|
$subscriberDeleteHandler = $this->getSubscriberDeleteHandlerMock( |
|
61
|
|
|
'{"errors":[{ "message":"Incorrect email", "code":"1321" }], "status":"errors"}' |
|
62
|
|
|
); |
|
63
|
|
|
$this->expectException(FreshMailSubscriberException::class); |
|
64
|
|
|
$subscriberDeleteHandler->deleteSubscriber('Test', 'Test'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function testListDoesntExist() |
|
68
|
|
|
{ |
|
69
|
|
|
$subscriberDeleteHandler = $this->getSubscriberDeleteHandlerMock( |
|
70
|
|
|
'{"errors":[{ "message":"The subscription list doesnt exist", "code":"1322" }], "status":"errors"}' |
|
71
|
|
|
); |
|
72
|
|
|
$this->expectException(FreshMailSubscriberException::class); |
|
73
|
|
|
$subscriberDeleteHandler->deleteSubscriber('Test', 'Test'); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
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