コード例 #1
0
ファイル: ModelTest.php プロジェクト: rodsouto/swizzle
 /**
  * Test array of models in response
  * @group mock
  * @depends testClientConstruct
  */
 public function testArrayResponse(Client $client)
 {
     // fake a response with multiple valid objects
     $plugin = new MockPlugin();
     $plugin->addResponse(new Response(200, array(), '[{"foo":1},{"foo":2},{"foo":3}]'));
     $client->addSubscriber($plugin);
     $response = $client->testlist();
     // response is a plain Response object
     $this->assertInstanceof('Guzzle\\Http\\Message\\Response', $response);
     // test response has contains items
     $data = $response->json();
     $this->assertCount(3, $data);
     // test if array items are models
     //$this->assertInstanceOf('\Guzzle\Service\Resource\Model', $data[0] );
     // They're not - they're arrays!
     $this->assertInternalType('array', $data[0]);
     $this->assertArrayHasKey('foo', $data[0]);
 }