Skip to content

Commit 03c0f36

Browse files
committed
Add unit test for startTime object formatting
1 parent 57c509f commit 03c0f36

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/unit/TransmissionTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ public function testSend() {
4444
$this->assertEquals($responseBody, $this->resource->send($body));
4545
}
4646

47+
public function testSendDateTimeConversion()
48+
{
49+
$testStartTime = new \DateTime("2016-08-27 13:01:02", new \DateTimeZone("UTC"));
50+
51+
$responseMock = Mockery::mock();
52+
$responseBody = ['results'=>'yay'];
53+
$this->sparkPostMock->httpAdapter->shouldReceive('send')->
54+
once()->
55+
with('/.*\/transmissions/', 'POST', Mockery::type('array'), matchesPattern('/"start_time":"2016-08-27T13:01:02\+00:00"/'))->
56+
andReturn($responseMock);
57+
$responseMock->shouldReceive('getStatusCode')->andReturn(200);
58+
$responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($responseBody));
59+
60+
$this->assertEquals($responseBody, $this->resource->send(['startTime'=>$testStartTime]));
61+
}
62+
4763
public function testAllWithFilter() {
4864
$responseMock = Mockery::mock();
4965
$responseBody = ['results'=>'yay'];

0 commit comments

Comments
 (0)