@@ -25,7 +25,8 @@ class CustomFieldTest extends TestCase
2525 public function testAllReturnsClientGetResponse ()
2626 {
2727 // Test values
28- $ response = 'API Response ' ;
28+ $ response = '["API Response"] ' ;
29+ $ expectedResponse = ['API Response ' ];
2930
3031 // Create the used mock objects
3132 $ client = $ this ->createMock (Client::class);
@@ -38,12 +39,15 @@ public function testAllReturnsClientGetResponse()
3839 $ client ->expects ($ this ->exactly (1 ))
3940 ->method ('getLastResponseBody ' )
4041 ->willReturn ($ response );
42+ $ client ->expects ($ this ->exactly (1 ))
43+ ->method ('getLastResponseContentType ' )
44+ ->willReturn ('application/json ' );
4145
4246 // Create the object under test
4347 $ api = new CustomField ($ client );
4448
4549 // Perform the tests
46- $ this ->assertSame ($ response , $ api ->all ());
50+ $ this ->assertSame ($ expectedResponse , $ api ->all ());
4751 }
4852
4953 /**
@@ -59,7 +63,8 @@ public function testAllReturnsClientGetResponseWithParameters()
5963 {
6064 // Test values
6165 $ allParameters = ['not-used ' ];
62- $ response = 'API Response ' ;
66+ $ response = '["API Response"] ' ;
67+ $ expectedResponse = ['API Response ' ];
6368
6469 // Create the used mock objects
6570 $ client = $ this ->createMock (Client::class);
@@ -72,12 +77,15 @@ public function testAllReturnsClientGetResponseWithParameters()
7277 $ client ->expects ($ this ->exactly (1 ))
7378 ->method ('getLastResponseBody ' )
7479 ->willReturn ($ response );
80+ $ client ->expects ($ this ->exactly (1 ))
81+ ->method ('getLastResponseContentType ' )
82+ ->willReturn ('application/json ' );
7583
7684 // Create the object under test
7785 $ api = new CustomField ($ client );
7886
7987 // Perform the tests
80- $ this ->assertSame ([ $ response ] , $ api ->all ($ allParameters ));
88+ $ this ->assertSame ($ expectedResponse , $ api ->all ($ allParameters ));
8189 }
8290
8391 /**
@@ -94,8 +102,8 @@ public function testAllReturnsClientGetResponseWithHighLimit()
94102 // Test values
95103 $ response = '{"limit":"100","items":[]} ' ;
96104 $ allParameters = ['limit ' => 250 ];
97- $ returnDataSet = [
98- 'limit ' => '100 ' ,
105+ $ expectedResponse = [
106+ 'limit ' => [ '100 ' , ' 100 ' , ' 100 ' ], // TODO: Check response created by array_merge_recursive()
99107 'items ' => [],
100108 ];
101109
@@ -118,10 +126,7 @@ public function testAllReturnsClientGetResponseWithHighLimit()
118126 $ api = new CustomField ($ client );
119127
120128 // Perform the tests
121- $ retrievedDataSet = $ api ->all ($ allParameters );
122- $ this ->assertTrue (is_array ($ retrievedDataSet ));
123- $ this ->assertArrayHasKey ('limit ' , $ retrievedDataSet );
124- $ this ->assertArrayHasKey ('items ' , $ retrievedDataSet );
129+ $ this ->assertSame ($ expectedResponse , $ api ->all ($ allParameters ));
125130 }
126131
127132 /**
0 commit comments