Skip to content

Commit ffb7f66

Browse files
committed
improved tests
1 parent f10ad84 commit ffb7f66

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* This file is part of the login-cidadao project or it's bundles.
4+
*
5+
* (c) Guilherme Donato <guilhermednt on github>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace PROCERGS\Sms\Tests\Protocols\V2;
12+
13+
use PROCERGS\Sms\Protocols\SmsStatusInterface;
14+
use PROCERGS\Sms\Protocols\V2\SmsStatus;
15+
16+
class SmsStatusTest extends \PHPUnit_Framework_TestCase
17+
{
18+
public function testSmsStatus()
19+
{
20+
$status = new SmsStatus(
21+
$dateSent = new \DateTime(),
22+
$dateDelivered = new \DateTime(),
23+
$statusCode = SmsStatusInterface::DELIVERED,
24+
$statusDesc = 'Some Description'
25+
);
26+
27+
$this->assertSame($dateSent, $status->getDateSent());
28+
$this->assertSame($dateDelivered, $status->getDateDelivered());
29+
$this->assertSame(SmsStatusInterface::DELIVERED, $status->getStatusCode());
30+
$this->assertSame($statusDesc, $status->getStatusDetails());
31+
$this->assertTrue($status->isFinal());
32+
}
33+
}

src/Tests/SmsServiceTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ public function testStatus()
251251
$this->assertNotNull($status->getStatus());
252252
}
253253

254+
/**
255+
* @throws \PROCERGS\Sms\Exception\SmsServiceException
256+
* @throws \PROCERGS\Sms\Exception\TransactionNotFoundException
257+
*/
254258
public function testStatusError()
255259
{
256260
$errorResponse = json_encode(
@@ -281,6 +285,28 @@ public function testStatusError()
281285
$smsService->getStatus($transactionId);
282286
}
283287

288+
/**
289+
* @throws \PROCERGS\Sms\Exception\SmsServiceException
290+
* @throws \PROCERGS\Sms\Exception\TransactionNotFoundException
291+
*/
292+
public function testStatusNotFound()
293+
{
294+
$this->setExpectedException('PROCERGS\Sms\Exception\TransactionNotFoundException');
295+
296+
$transactionId = 'error';
297+
298+
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
299+
$response->expects($this->once())->method('isOk')->willReturn(false);
300+
$response->expects($this->once())->method('isNotFound')->willReturn(true);
301+
302+
$restClient = $this->getSimpleRestClient();
303+
$restClient->expects($this->once())->method('get')->willReturn($response);
304+
305+
/** @var SmsService $smsService */
306+
$smsService = $this->getSmsService($restClient);
307+
$smsService->getStatus($transactionId);
308+
}
309+
284310
private function getSimpleRestClient($response = null)
285311
{
286312
$restClient = $this->getRestClient();

0 commit comments

Comments
 (0)