summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/SparkPostTest.php5
-rw-r--r--test/unit/TransmissionTest.php31
2 files changed, 26 insertions, 10 deletions
diff --git a/test/unit/SparkPostTest.php b/test/unit/SparkPostTest.php
index 218cb6e..b019a15 100644
--- a/test/unit/SparkPostTest.php
+++ b/test/unit/SparkPostTest.php
@@ -7,6 +7,7 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase {
/**
* @desc Ensures that the configuration class is not instantiable.
+ * @covers SparkPost::__construct
*/
public function testConstructorCannotBeCalled() {
$class = new \ReflectionClass('\MessageSystems\SparkPost');
@@ -16,6 +17,7 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase {
/**
* @desc Tests that an exception is thrown when a library tries to recieve the config and it has not yet been set.
* Since its a singleton this test must come before any setConfig tests.
+ * @covers SparkPost::getConfig
* @expectedException Exception
* @expectedExceptionMessage No configuration has been provided
*/
@@ -25,6 +27,7 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase {
/**
* @desc Tests that the api key is set when setting the config
+ * @covers SparkPost::setConfig
* @expectedException Exception
* @expectedExceptionMessage You must provide an API key
*/
@@ -34,6 +37,7 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase {
/**
* @desc Tests that the api key is set when setting the config and that its not empty
+ * @covers SparkPost::setConfig
* @expectedException Exception
* @expectedExceptionMessage You must provide an API key
*/
@@ -43,6 +47,7 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase {
/**
* @desc Tests overridable values are set while invalid values are ignored
+ * @covers SparkPost::setConfig
*/
public function testSetConfigMultipleValuesAndGetConfig() {
SparkPost::setConfig(['key'=>'lala', 'version'=>'v8', 'port'=>1024, 'someOtherValue'=>'fakeValue']);
diff --git a/test/unit/TransmissionTest.php b/test/unit/TransmissionTest.php
index 8da2645..0e71ddf 100644
--- a/test/unit/TransmissionTest.php
+++ b/test/unit/TransmissionTest.php
@@ -8,14 +8,18 @@ use GuzzleHttp\Message\Response;
use GuzzleHttp\Stream\Stream;
-/**
- *
- *
- */
class TransmissionTest extends \PHPUnit_Framework_TestCase {
private $client = null;
+ /**
+ * Allows access to private methods in the Transmission class
+ *
+ * This is needed to mock the GuzzleHttp\Client responses
+ *
+ * @param string $name
+ * @return ReflectionMethod
+ */
private static function getMethod($name) {
$class = new \ReflectionClass('\MessageSystems\Transmission');
$method = $class->getMethod($name);
@@ -35,6 +39,7 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase {
/**
* @desc Ensures that the configuration class is not instantiable.
+ * @covers Transmission::__construct
*/
public function testConstructorCannotBeCalled() {
$class = new \ReflectionClass('\MessageSystems\Transmission');
@@ -42,7 +47,8 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase {
}
/**
- *
+ * @desc tests happy path
+ * @covers Transmission::all
*/
public function testAllWithGoodResponse() {
$mock = new Mock([new Response(200, [], Stream::factory('{"results":[{"test":"This is a test"}, {"test":"two"}]}'))]);
@@ -52,7 +58,8 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase {
}
/**
- *
+ * @desc tests happy path
+ * @covers Transmission::find
*/
public function testFindWithGoodResponse() {
$mock = new Mock([new Response(200, [], Stream::factory('{"results":[{"test":"This is a test"}]}'))]);
@@ -62,7 +69,8 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase {
}
/**
- *
+ * @desc tests 404 bad response
+ * @covers Transmission::find
*/
public function testFindWith404Response() {
$mock = new Mock([new Response(404, [])]);
@@ -77,7 +85,8 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase {
}
/**
- *
+ * @desc tests unknown bad response
+ * @covers Transmission::find
*/
public function testFindWithOtherBadResponse() {
$mock = new Mock([new Response(400, [])]);
@@ -92,7 +101,8 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase {
}
/**
- *
+ * @desc tests happy path
+ * @covers Transmission::send
*/
public function testSuccessfulSend() {
$body = ["result"=>["transmission_id"=> "11668787484950529"], "status"=>["message"=> "ok","code"=> "1000"]];
@@ -103,7 +113,8 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase {
}
/**
- *
+ * @desc tests bad response
+ * @covers Transmission::send
*/
public function testSendForRequestException() {
$body = ['errors'=>['This is a fake error']];