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