diff options
author | James Fellows <james.fellows@finanscapes.com> | 2016-04-04 23:20:07 +0100 |
---|---|---|
committer | James Fellows <james.fellows@finanscapes.com> | 2016-04-04 23:20:07 +0100 |
commit | 0a3035c4bd322a8c88313ab93deda0ac032e7f95 (patch) | |
tree | dfe41bc92649066fcc4dfe8f12421dab6a2bcac7 | |
parent | 03c0f363fc17e555583b32b8a0ff7f73f9b46d20 (diff) | |
download | php-sparkpost-0a3035c4bd322a8c88313ab93deda0ac032e7f95.zip php-sparkpost-0a3035c4bd322a8c88313ab93deda0ac032e7f95.tar.gz php-sparkpost-0a3035c4bd322a8c88313ab93deda0ac032e7f95.tar.bz2 |
Add unit tests for Message Events::documentation and ::samples
-rw-r--r-- | lib/SparkPost/MessageEvent.php | 6 | ||||
-rw-r--r-- | test/unit/MessageEventTest.php | 26 |
2 files changed, 29 insertions, 3 deletions
diff --git a/lib/SparkPost/MessageEvent.php b/lib/SparkPost/MessageEvent.php index e770642..d2fe11c 100644 --- a/lib/SparkPost/MessageEvent.php +++ b/lib/SparkPost/MessageEvent.php @@ -44,9 +44,9 @@ class MessageEvent extends APIResource } /** - * List an example of the event data that will be included in a response from the MessageEvent::search() method. + * List examples of the event data that will be included in a response from the MessageEvent::search() method. */ - public function samples() { - return $this->get("events/samples", ["events" => "bounce"]); + public function samples(Array $events) { + return $this->get("events/samples", ["events"=>$events]); } }
\ No newline at end of file diff --git a/test/unit/MessageEventTest.php b/test/unit/MessageEventTest.php index a91d17a..935939d 100644 --- a/test/unit/MessageEventTest.php +++ b/test/unit/MessageEventTest.php @@ -42,4 +42,30 @@ class MessageEventTest extends \PHPUnit_Framework_TestCase $this->assertEquals($testBody, $this->sut->search(["from" => $testFrom, "to" => $testTo])); } + + public function testDocumentation() { + $testBody = ['results' => ['my' => 'test']]; + $responseMock = Mockery::mock(); + $this->sparkPostMock->httpAdapter->shouldReceive('send')-> + once()-> + with("/message-events/events/documentation", 'GET', Mockery::type('array'), null)-> + andReturn($responseMock); + $responseMock->shouldReceive('getStatusCode')->andReturn(200); + $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody)); + + $this->assertEquals($testBody, $this->sut->documentation()); + } + + public function testSamples() { + $testBody = ['results' => ['my' => 'test']]; + $responseMock = Mockery::mock(); + $this->sparkPostMock->httpAdapter->shouldReceive('send')-> + once()-> + with("/message-events/events/samples?events=".urlencode("delivery,bounce"), 'GET', Mockery::type('array'), null)-> + andReturn($responseMock); + $responseMock->shouldReceive('getStatusCode')->andReturn(200); + $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody)); + + $this->assertEquals($testBody, $this->sut->samples(["delivery", "bounce"])); + } }
\ No newline at end of file |