1 | <?php |
||||
2 | /** |
||||
3 | * File: SubscriberAddHandlerTest.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\SubscriberAddHandler; |
||||
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 SubscriberAddHandlerTest |
||||
19 | * |
||||
20 | * @package MSlwk\FreshMail\Test\Subscriber |
||||
21 | */ |
||||
22 | class SubscriberAddHandlerTest extends TestCase |
||||
23 | { |
||||
24 | use BaseTest; |
||||
25 | |||||
26 | /** |
||||
27 | * @param $sendRequestReturnValue |
||||
28 | * @return \PHPUnit_Framework_MockObject_MockObject |
||||
0 ignored issues
–
show
|
|||||
29 | */ |
||||
30 | public function getSubscriberAddHandlerMock($sendRequestReturnValue) |
||||
31 | { |
||||
32 | $subscriberAddHandler = $this->getMockBuilder('\MSlwk\FreshMail\Handler\Subscriber\SubscriberAddHandler') |
||||
0 ignored issues
–
show
The function
PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
33 | ->setConstructorArgs([new ErrorHandler(), '', '']) |
||||
34 | ->setMethods(['sendRequest']) |
||||
35 | ->getMock(); |
||||
36 | |||||
37 | $subscriberAddHandler->expects($this->once()) |
||||
38 | ->method('sendRequest') |
||||
39 | ->will($this->returnValue($sendRequestReturnValue)); |
||||
40 | |||||
41 | return $subscriberAddHandler; |
||||
0 ignored issues
–
show
|
|||||
42 | } |
||||
43 | |||||
44 | public function testSubscriberAddedSuccessfully() |
||||
45 | { |
||||
46 | $subscriberAddHandler = $this->getSubscriberAddHandlerMock('{"status":"OK"}'); |
||||
47 | self::assertNull($subscriberAddHandler->addSubscriber('Test', 'Test')); |
||||
48 | } |
||||
49 | |||||
50 | public function testApiEndpoint() |
||||
51 | { |
||||
52 | $subscriberAddHandler = new SubscriberAddHandler(new ErrorHandler(), '', ''); |
||||
53 | $expectedApiEndpoint = '/rest/subscriber/add'; |
||||
54 | $returnedApiEndpoint = $this->getApiEndpoint($subscriberAddHandler); |
||||
55 | self::assertEquals($expectedApiEndpoint, $returnedApiEndpoint); |
||||
56 | } |
||||
57 | |||||
58 | public function testIncorrectEmail() |
||||
59 | { |
||||
60 | $subscriberAddHandler = $this->getSubscriberAddHandlerMock( |
||||
61 | '{"errors":[{ "message":"Incorrect email", "code":"1301" }], "status":"errors"}' |
||||
62 | ); |
||||
63 | $this->expectException(FreshMailSubscriberException::class); |
||||
64 | $subscriberAddHandler->addSubscriber('Test', 'Test'); |
||||
65 | } |
||||
66 | |||||
67 | public function testListDoesntExist() |
||||
68 | { |
||||
69 | $subscriberAddHandler = $this->getSubscriberAddHandlerMock( |
||||
70 | '{"errors":[{ "message":"The subscription list doesnt exist", "code":"1302" }], "status":"errors"}' |
||||
71 | ); |
||||
72 | $this->expectException(FreshMailSubscriberException::class); |
||||
73 | $subscriberAddHandler->addSubscriber('Test', 'Test'); |
||||
74 | } |
||||
75 | |||||
76 | public function testCustomFieldsIncorrect() |
||||
77 | { |
||||
78 | $subscriberAddHandler = $this->getSubscriberAddHandlerMock( |
||||
79 | '{"errors":[{ "message":"At least one custom field is incorrect", "code":"1303" }], "status":"errors"}' |
||||
80 | ); |
||||
81 | $this->expectException(FreshMailSubscriberException::class); |
||||
82 | $subscriberAddHandler->addSubscriber('Test', 'Test'); |
||||
83 | } |
||||
84 | |||||
85 | public function testSubscriberAlreadyExists() |
||||
86 | { |
||||
87 | $subscriberAddHandler = $this->getSubscriberAddHandlerMock( |
||||
88 | '{"errors":[{ "message":"Subscriber already exists", "code":"1304" }], "status":"errors"}' |
||||
89 | ); |
||||
90 | $this->expectException(FreshMailSubscriberException::class); |
||||
91 | $subscriberAddHandler->addSubscriber('Test', 'Test'); |
||||
92 | } |
||||
93 | |||||
94 | public function testIncorrectStatus() |
||||
95 | { |
||||
96 | $subscriberAddHandler = $this->getSubscriberAddHandlerMock( |
||||
97 | '{"errors":[{ "message":"You tried to assign an incorrect status", "code":"1305" }], "status":"errors"}' |
||||
98 | ); |
||||
99 | $this->expectException(FreshMailSubscriberException::class); |
||||
100 | $subscriberAddHandler->addSubscriber('Test', 'Test'); |
||||
101 | } |
||||
102 | } |
||||
103 |
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