Skip to content

Commit cb2e986

Browse files
committed
Increase code coverage.
1 parent abbcfc4 commit cb2e986

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

src/main/php/Gomoob/Pushwoosh/Client/PushwooshMock.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,11 @@ public function createMessage(CreateMessageRequest $createMessageRequest)
9393
*/
9494
public function createTargetedMessage(CreateTargetedMessageRequest $createTargetedMessageRequest)
9595
{
96-
// If the 'auth' parameter is not set in the request we try to get it from the Pushwoosh client
97-
$this->setAuthIfNotSet($createTargetedMessageRequest);
98-
9996
return CreateTargetedMessageResponse::create(
10097
json_decode('{
10198
"status_code":200,
10299
"status_message":"OK",
103-
"response": {
104-
"Messages":[]
105-
}
100+
"response": {}
106101
}', true)
107102
);
108103
}

src/test/php/Gomoob/Pushwoosh/Client/PushwooshMockTest.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use PHPUnit\Framework\TestCase;
1212
use Gomoob\Pushwoosh\Model\Request\CreateMessageRequest;
13+
use Gomoob\Pushwoosh\Model\Request\CreateTargetedMessageRequest;
1314

1415
/**
1516
* Test case used to test the `PushwooshMock` class.
@@ -32,7 +33,8 @@ public function testCreateMessage()
3233
$this->assertCount(0, $pushwooshMock->getPushwooshRequests());
3334

3435
// Test call
35-
$createMessageResponse = $pushwooshMock->createMessage(CreateMessageRequest::create());
36+
$createMessageRequest = CreateMessageRequest::create();
37+
$createMessageResponse = $pushwooshMock->createMessage($createMessageRequest);
3638

3739
$this->assertNotNull($createMessageResponse);
3840
$this->assertSame(200, $createMessageResponse->getStatusCode());
@@ -42,5 +44,33 @@ public function testCreateMessage()
4244
$createMessageResponseResponse = $createMessageResponse->getResponse();
4345
$this->assertNotNull($createMessageResponseResponse);
4446
$this->assertCount(0, $createMessageResponseResponse->getMessages());
47+
48+
// One more requests has been send
49+
$this->assertCount(1, $pushwooshMock->getPushwooshRequests());
50+
$this->assertSame($createMessageRequest, $pushwooshMock->getPushwooshRequests()[0]);
51+
}
52+
53+
/**
54+
* Test method for the `createTargetedMessage(CreateTargetedMessageRequest $createTargetedMessageRequest)` function.
55+
*
56+
* @group PushwooshTest.createTargetedMessage
57+
*/
58+
public function testCreateTargetedMessage()
59+
{
60+
$pushwooshMock = new PushwooshMock();
61+
62+
// At the beginning no pushwoosh requests have been sent
63+
$this->assertCount(0, $pushwooshMock->getPushwooshRequests());
64+
65+
// Test call
66+
$createTargetedMessageResponse = $pushwooshMock->createTargetedMessage(CreateTargetedMessageRequest::create());
67+
68+
$this->assertNotNull($createTargetedMessageResponse);
69+
$this->assertSame(200, $createTargetedMessageResponse->getStatusCode());
70+
$this->assertSame('OK', $createTargetedMessageResponse->getStatusMessage());
71+
$this->assertTrue($createTargetedMessageResponse->isOk());
72+
73+
$createTargetedMessageResponseResponse = $createTargetedMessageResponse->getResponse();
74+
$this->assertNotNull($createTargetedMessageResponseResponse);
4575
}
4676
}

0 commit comments

Comments
 (0)