Skip to content

Commit 2368aa3

Browse files
committed
Fix exceptions and tests
1 parent 806336d commit 2368aa3

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

src/ScayTrase/WebSMS/Connection/AbstractWebSMSConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function doSendRequest(MessageInterface $message)
8181
if ($status[DriverInterface::NORMALIZED_CODE] !== DriverInterface::STATUS_OK) {
8282
throw new DeliveryException(
8383
$message,
84-
$status[DriverInterface::STATUS_OK],
84+
$status[DriverInterface::NORMALIZED_MESSAGE],
8585
$status[DriverInterface::NORMALIZED_CODE]
8686
);
8787
}

src/ScayTrase/WebSMS/Exception/ConnectionException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace ScayTrase\WebSMS\Exception;
1010

11-
class ConnectionException extends \Exception
11+
class ConnectionException extends WebSMSException
1212
{
1313

1414
}

src/ScayTrase/WebSMS/Exception/DriverException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace ScayTrase\WebSMS\Exception;
1010

11-
class DriverException extends \Exception
11+
class DriverException extends WebSMSException
1212
{
1313

1414
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Pavel
5+
* Date: 2015-05-25
6+
* Time: 20:37
7+
*/
8+
9+
namespace ScayTrase\WebSMS\Exception;
10+
11+
class WebSMSException extends \Exception
12+
{
13+
14+
}

src/ScayTrase/WebSMS/Tests/DriverTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
use ScayTrase\WebSMS\Connection\Connection;
1212
use ScayTrase\WebSMS\Driver\DriverInterface;
13+
use ScayTrase\WebSMS\Exception\DeliveryException;
14+
use ScayTrase\WebSMS\Exception\DriverException;
15+
use ScayTrase\WebSMS\Exception\WebSMSException;
1316

1417
class DriverTest extends AbstractWebSMSTest
1518
{
@@ -60,8 +63,6 @@ public function invalidCredentialsProvider()
6063
}
6164

6265
/**
63-
* @expectedException \ScayTrase\WebSMS\Exception\DriverException
64-
*
6566
* @param DriverInterface $driver
6667
* @param $username
6768
* @param $password
@@ -73,6 +74,17 @@ public function testInvalidCredentialsHandling(DriverInterface $driver, $usernam
7374
$connection = new Connection($driver, $username, $password, Connection::TEST_ENABLED);
7475
$message = $this->getMessageMock();
7576

76-
$connection->send($message);
77+
try {
78+
$connection->send($message);
79+
} catch (WebSMSException $exception) {
80+
if ($exception instanceof DeliveryException){
81+
return;
82+
} elseif ($exception instanceof DriverException){
83+
return;
84+
} else {
85+
$this->fail('Unexpected exception');
86+
}
87+
88+
}
7789
}
7890
}

0 commit comments

Comments
 (0)