1 | <?php |
||||
2 | /** |
||||
3 | * File: CampaignDeleteHandlerTest.php |
||||
4 | * |
||||
5 | * @author Maciej Sławik <[email protected]> |
||||
6 | * Github: https://github.com/maciejslawik |
||||
7 | */ |
||||
8 | |||||
9 | namespace MSlwk\FreshMail\Test\Campaign; |
||||
10 | |||||
11 | use MSlwk\FreshMail\Handler\Campaign\CampaignDeleteHandler; |
||||
12 | use MSlwk\FreshMail\Tests\BaseTest; |
||||
13 | use PHPUnit\Framework\TestCase; |
||||
14 | use MSlwk\FreshMail\Error\ErrorHandler; |
||||
15 | use MSlwk\FreshMail\Exception\Campaign\FreshMailCampaignException; |
||||
16 | |||||
17 | /** |
||||
18 | * Class CampaignDeleteHandlerTest |
||||
19 | * |
||||
20 | * @package MSlwk\FreshMail\Test\Campaign |
||||
21 | */ |
||||
22 | class CampaignDeleteHandlerTest 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 getCampaignDeleteHandlerMock($sendRequestReturnValue) |
||||
31 | { |
||||
32 | $campaignDeleteHandler = $this->getMockBuilder('\MSlwk\FreshMail\Handler\Campaign\CampaignDeleteHandler') |
||||
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 | $campaignDeleteHandler->expects($this->once()) |
||||
38 | ->method('sendRequest') |
||||
39 | ->will($this->returnValue($sendRequestReturnValue)); |
||||
40 | |||||
41 | return $campaignDeleteHandler; |
||||
0 ignored issues
–
show
|
|||||
42 | } |
||||
43 | |||||
44 | public function testCampaignDeleteSuccessful() |
||||
45 | { |
||||
46 | $campaignDeleteHandler = $this->getCampaignDeleteHandlerMock('{"status":"OK"}'); |
||||
47 | $returnValue = $campaignDeleteHandler->deleteCampaign('id_hash'); |
||||
48 | self::assertNull($returnValue); |
||||
49 | } |
||||
50 | |||||
51 | public function testApiEndpoint() |
||||
52 | { |
||||
53 | $accountCreateHandler = new CampaignDeleteHandler(new ErrorHandler(), '', ''); |
||||
54 | $expectedApiEndpoint = '/rest/campaigns/delete'; |
||||
55 | $returnedApiEndpoint = $this->getApiEndpoint($accountCreateHandler); |
||||
56 | self::assertEquals($expectedApiEndpoint, $returnedApiEndpoint); |
||||
57 | } |
||||
58 | |||||
59 | public function testCampaignDoesntExist() |
||||
60 | { |
||||
61 | $campaignDeleteHandler = $this->getCampaignDeleteHandlerMock( |
||||
62 | '{"errors":[{ "message":"Requested campaign doesnt exist", "code":"1724" }], "status":"errors"}' |
||||
63 | ); |
||||
64 | $this->expectException(FreshMailCampaignException::class); |
||||
65 | $campaignDeleteHandler->deleteCampaign('id_hash'); |
||||
66 | } |
||||
67 | |||||
68 | public function testCampaignAlreadyDeleted() |
||||
69 | { |
||||
70 | $campaignDeleteHandler = $this->getCampaignDeleteHandlerMock( |
||||
71 | '{"errors":[{ "message":"Campaign cant be deleted", "code":"1798" }], "status":"errors"}' |
||||
72 | ); |
||||
73 | $this->expectException(FreshMailCampaignException::class); |
||||
74 | $campaignDeleteHandler->deleteCampaign('id_hash'); |
||||
75 | } |
||||
76 | } |
||||
77 |
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