diff options
-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 |