/** * Results constructor. * * @param \Google_Service_Datastore_RunQueryResponse $response */ public function __construct($response) { $batch = $response->getBatch(); $this->endCursor = $batch->getEndCursor(); $this->entityResultType = $batch->getEntityResultType(); $this->moreResults = $batch->getMoreResults(); $this->skippedResults = $batch->getSkippedResults(); $batch->getEntityResults(); $this->entities = []; /** @var \Google_Service_Datastore_EntityResult $entityResult */ foreach ($batch as $entityResult) { $this->entities[] = $entityResult->getEntity(); } }
public function testFetchMessages() { // set up mock objects $apiResponse = new \Google_Service_Datastore_RunQueryResponse(); $apiResponse->setBatch(new \Google_Service_Datastore_QueryResultBatch()); $apiClient = $this->getMock('Google_Client'); $apiClient->expects($this->once())->method('execute')->will($this->returnValue($apiResponse)); $apiClient->expects($this->once())->method('getLogger')->will($this->returnValue($this->getMock('Psr\\Log\\LoggerInterface'))); $apiClient->expects($this->once())->method('getHttpClient')->will($this->returnValue(new HttpClient())); // create the application $app = $this->createApplication(); $app['google_client'] = $apiClient; $client = new Client($app); // make the request $crawler = $client->request('GET', '/fetch_messages'); // test the response $response = $client->getResponse(); $this->assertTrue($response->isOk()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\JsonResponse', $response); $this->assertEquals('[]', $response->getContent()); }