/** * Test Fetch With Ancestors */ public function testFetchWithAncestors() { $obj_gateway = new GDS\Gateway\GoogleAPIClient($this->setupTestClient(), 'Dataset'); $obj_store = new \GDS\Store('Person', $obj_gateway); $this->expectRequest('https://www.googleapis.com/datastore/v1beta2/datasets/Dataset/runQuery', '{"gqlQuery":{"allowLiteral":true,"queryString":"SELECT * FROM Person LIMIT @intPageSize ","nameArgs":[{"name":"intPageSize","value":{"integerValue":1}}]}}', '{"batch": {"entityResultType": "FULL","entityResults": [{"entity": {"key":{"partitionId": {"datasetId": "Dataset"},"path":[{"kind":"Person","name":"Johnny"},{"kind":"Person","id": "4804129360707584"}]},"properties":{"name":{"indexed":true,"stringValue":"Tom"},"age":{"indexed":true,"integerValue":36},"dob":{"dateTimeValue":"1979-02-04T08:30:00+00:00","indexed":true},"weight":{"doubleValue":94.5,"indexed":true},"likes_php":{"booleanValue":true,"indexed":true},"friends":{"listValue":[{"indexed":true,"stringValue":"Tom"},{"indexed":true,"stringValue":"Dick"},{"indexed":true,"stringValue":"Harry"}]}}}}],"endCursor": "CiQSHmoJc35waHAtZ2RzchELEgRCb29rGICAgMDIqsQIDBgAIAA=","moreResults": "MORE_RESULTS_AFTER_LIMIT","skippedResults": null}}'); $arr_result = $obj_store->query("SELECT * FROM Person")->fetchPage(1); $this->assertTrue(is_array($arr_result)); $this->assertEquals(1, count($arr_result)); $obj_result = $arr_result[0]; $this->assertInstanceOf('\\GDS\\Entity', $obj_result); $this->assertEquals('4804129360707584', $obj_result->getKeyId()); $this->assertEquals([['kind' => 'Person', 'id' => null, 'name' => 'Johnny']], $obj_result->getAncestry()); $this->assertEquals('CiQSHmoJc35waHAtZ2RzchELEgRCb29rGICAgMDIqsQIDBgAIAA=', $obj_store->getCursor()); }
public function testOrderedLimitFallback() { $obj_deny_proxy = new DenyGQLProxyMock(); $obj_deny_proxy->init($this); $obj_request = new \google\appengine\datastore\v4\RunQueryRequest(); $obj_request->setSuggestedBatchSize(1000); $obj_request->mutableReadOptions(); $obj_partition = $obj_request->mutablePartitionId(); $obj_partition->setDatasetId('Dataset'); $obj_query = $obj_request->mutableQuery(); $obj_query->addKind()->setName('Book'); $obj_query->setLimit(20); $obj_query->addOrder()->setDirection(\google\appengine\datastore\v4\PropertyOrder\Direction::DESCENDING)->mutableProperty()->setName('author'); $obj_deny_proxy->expectCall('datastore_v4', 'RunQuery', $obj_request, new \google\appengine\datastore\v4\RunQueryResponse()); $obj_gateway = new GDS\Gateway\ProtoBuf('Dataset'); $obj_store = new GDS\Store('Book', $obj_gateway); $obj_store->query("SELECT * FROM Book ORDER BY author DESC")->fetchPage(20); $obj_deny_proxy->verify(); }