Skip to content

Commit 8cb5dd9

Browse files
committed
Updated unit tests
1 parent 267b9c7 commit 8cb5dd9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

test/unit/APIResourceTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public function testCreate() {
5151
once()->
5252
with(Mockery::type('string'), 'POST', Mockery::type('array'), json_encode($testInput))->
5353
andReturn($responseMock);
54+
$responseMock->shouldReceive('getStatusCode')->andReturn(200);
5455
$responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
5556

56-
5757
$this->assertEquals($testBody, $this->resource->create($testInput));
5858
}
5959

@@ -65,6 +65,7 @@ public function testUpdate() {
6565
once()->
6666
with('/.*\/test/', 'PUT', Mockery::type('array'), json_encode($testInput))->
6767
andReturn($responseMock);
68+
$responseMock->shouldReceive('getStatusCode')->andReturn(200);
6869
$responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
6970

7071
$this->assertEquals($testBody, $this->resource->update('test', $testInput));
@@ -77,6 +78,7 @@ public function testGet() {
7778
once()->
7879
with('/.*\/test/', 'GET', Mockery::type('array'), null)->
7980
andReturn($responseMock);
81+
$responseMock->shouldReceive('getStatusCode')->andReturn(200);
8082
$responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
8183

8284
$this->assertEquals($testBody, $this->resource->get('test'));
@@ -88,16 +90,19 @@ public function testDelete() {
8890
once()->
8991
with('/.*\/test/', 'DELETE', Mockery::type('array'), null)->
9092
andReturn($responseMock);
93+
$responseMock->shouldReceive('getStatusCode')->andReturn(200);
9194
$responseMock->shouldReceive('getBody->getContents')->andReturn('');
9295

9396
$this->assertEquals(null, $this->resource->delete('test'));
9497
}
9598

9699
public function testAdapter404Exception() {
97100
try {
101+
$responseMock = Mockery::mock();
98102
$this->sparkPostMock->httpAdapter->shouldReceive('send')->
99103
once()->
100-
andThrow($this->getExceptionMock(404));
104+
andReturn($responseMock);
105+
$responseMock->shouldReceive('getStatusCode')->andReturn(404);
101106

102107
$this->resource->get('test');
103108
}
@@ -108,9 +113,11 @@ public function testAdapter404Exception() {
108113

109114
public function testAdapter4XXException() {
110115
try {
116+
$responseMock = Mockery::mock();
111117
$this->sparkPostMock->httpAdapter->shouldReceive('send')->
112118
once()->
113-
andThrow($this->getExceptionMock(400));
119+
andReturn($responseMock);
120+
$responseMock->shouldReceive('getStatusCode')->andReturn(400);
114121

115122
$this->resource->get('test');
116123
}

test/unit/TransmissionTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function testSend() {
3737
once()->
3838
with('/.*\/transmissions/', 'POST', Mockery::type('array'), Mockery::type('string'))->
3939
andReturn($responseMock);
40+
$responseMock->shouldReceive('getStatusCode')->andReturn(200);
4041

4142
$responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($responseBody));
4243

@@ -50,6 +51,7 @@ public function testAllWithFilter() {
5051
once()->
5152
with('/.*transmissions.*?campaign_id=campaign&template_id=template/', 'GET', Mockery::type('array'), null)->
5253
andReturn($responseMock);
54+
$responseMock->shouldReceive('getStatusCode')->andReturn(200);
5355

5456
$responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($responseBody));
5557

@@ -63,6 +65,7 @@ public function testAllWithOutFilter() {
6365
once()->
6466
with('/.*\/transmissions/', 'GET', Mockery::type('array'), null)->
6567
andReturn($responseMock);
68+
$responseMock->shouldReceive('getStatusCode')->andReturn(200);
6669

6770
$responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($responseBody));
6871

@@ -76,6 +79,7 @@ public function testFind() {
7679
once()->
7780
with('/.*\/transmissions.*\/test/', 'GET', Mockery::type('array'), null)->
7881
andReturn($responseMock);
82+
$responseMock->shouldReceive('getStatusCode')->andReturn(200);
7983

8084
$responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($responseBody));
8185

0 commit comments

Comments
 (0)