/**
  * Attempt an upsert with an unrecognised property type
  *
  * @expectedException        Exception
  * @expectedExceptionMessage Mismatch count of requested & returned Auto IDs
  */
 public function testUnknownTypes()
 {
     $obj_request = new \google\appengine\datastore\v4\CommitRequest();
     $obj_request->setMode(\google\appengine\datastore\v4\CommitRequest\Mode::NON_TRANSACTIONAL);
     $obj_mutation = $obj_request->mutableDeprecatedMutation();
     $obj_entity = $obj_mutation->addInsertAutoId();
     $obj_key = $obj_entity->mutableKey();
     $obj_partition = $obj_key->mutablePartitionId();
     $obj_partition->setDatasetId('Dataset');
     $obj_kpe = $obj_key->addPathElement();
     $obj_kpe->setKind('Book');
     $obj_property = $obj_entity->addProperty();
     $obj_property->setName('property');
     $obj_val = $obj_property->mutableValue();
     $obj_val->setIndexed(TRUE);
     // $obj_val->setStringValue('');
     $obj_property = $obj_entity->addProperty();
     $obj_property->setName('simple');
     $obj_val = $obj_property->mutableValue();
     $obj_val->setIndexed(TRUE);
     $obj_val->setStringValue('success!');
     $obj_property = $obj_entity->addProperty();
     $obj_property->setName('blank');
     $obj_val = $obj_property->mutableValue();
     $obj_val->setIndexed(TRUE);
     $this->apiProxyMock->expectCall('datastore_v4', 'Commit', $obj_request, new \google\appengine\datastore\v4\CommitResponse());
     $obj_store = $this->createBasicStore();
     $obj_store->upsert($obj_store->createEntity(['property' => new stdClass(), 'simple' => new Simple(), 'blank' => null]));
     $this->apiProxyMock->verify();
 }
 /**
  * Delete one, with namespace
  */
 public function testDeleteOne()
 {
     $obj_request = new \google\appengine\datastore\v4\CommitRequest();
     $obj_request->setMode(\google\appengine\datastore\v4\CommitRequest\Mode::NON_TRANSACTIONAL);
     $obj_mutation = $obj_request->mutableDeprecatedMutation();
     $obj_key = $obj_mutation->addDelete();
     $obj_key->mutablePartitionId()->setDatasetId('Dataset')->setNamespace('Test');
     $obj_key->addPathElement()->setKind('Book')->setName('PoEAA');
     $this->apiProxyMock->expectCall('datastore_v4', 'Commit', $obj_request, new \google\appengine\datastore\v4\CommitResponse());
     $obj_store = $this->getBookstoreWithTestNamespace();
     $obj_result = $obj_store->delete($obj_store->createEntity()->setKeyName('PoEAA'));
     $this->assertEquals($obj_result, TRUE);
     $this->apiProxyMock->verify();
 }
 /**
  * Delete many
  */
 public function testDeleteMany()
 {
     $obj_request = new \google\appengine\datastore\v4\CommitRequest();
     $obj_request->setMode(\google\appengine\datastore\v4\CommitRequest\Mode::NON_TRANSACTIONAL);
     $obj_mutation = $obj_request->mutableDeprecatedMutation();
     $obj_key = $obj_mutation->addDelete();
     $obj_partition = $obj_key->mutablePartitionId();
     $obj_partition->setDatasetId('Dataset');
     $obj_kpe = $obj_key->addPathElement();
     $obj_kpe->setKind('Book');
     $obj_kpe->setId(9876543321);
     $obj_key = $obj_mutation->addDelete();
     $obj_partition = $obj_key->mutablePartitionId();
     $obj_partition->setDatasetId('Dataset');
     $obj_kpe = $obj_key->addPathElement();
     $obj_kpe->setKind('Book');
     $obj_kpe->setId(9876543322);
     $this->apiProxyMock->expectCall('datastore_v4', 'Commit', $obj_request, new \google\appengine\datastore\v4\CommitResponse());
     $obj_store = $this->createBasicStore();
     $obj_result = $obj_store->delete([$obj_store->createEntity()->setKeyId(9876543321), $obj_store->createEntity()->setKeyId(9876543322)]);
     $this->assertEquals($obj_result, TRUE);
     $this->apiProxyMock->verify();
 }
 /**
  * Insert One WITH result
  */
 public function testUpsertOneAutoIdWithResult()
 {
     $obj_request = new \google\appengine\datastore\v4\CommitRequest();
     $obj_request->setMode(\google\appengine\datastore\v4\CommitRequest\Mode::NON_TRANSACTIONAL);
     $obj_mutation = $obj_request->mutableDeprecatedMutation();
     $obj_entity = $obj_mutation->addInsertAutoId();
     $obj_key = $obj_entity->mutableKey();
     $obj_partition = $obj_key->mutablePartitionId();
     $obj_partition->setDatasetId('Dataset');
     $obj_kpe = $obj_key->addPathElement();
     $obj_kpe->setKind('Film');
     $obj_property = $obj_entity->addProperty();
     $obj_property->setName('title');
     $obj_val = $obj_property->mutableValue();
     $obj_val->setIndexed(TRUE);
     $obj_val->setStringValue('Back to the Future');
     $obj_response = new \google\appengine\datastore\v4\CommitResponse();
     $obj_mutation_result = $obj_response->mutableDeprecatedMutationResult();
     $obj_ai_key = $obj_mutation_result->addInsertAutoIdKey();
     $obj_ai_kpe = $obj_ai_key->addPathElement();
     $obj_ai_kpe->setKind('Film')->setId(499190400);
     $this->apiProxyMock->expectCall('datastore_v4', 'Commit', $obj_request, $obj_response);
     $obj_gateway = new GDS\Gateway\ProtoBuf('Dataset');
     $obj_store = new GDS\Store('Film', $obj_gateway);
     $obj_book = $obj_store->createEntity(['title' => 'Back to the Future']);
     $obj_store->upsert($obj_book);
     $this->assertEquals(499190400, $obj_book->getKeyId());
     $this->apiProxyMock->verify();
 }