Пример #1
0
 /**
  * Ensure parameters can be retrieved en masse
  */
 public function testGetData()
 {
     $obj_entity = new GDS\Entity();
     $obj_entity->setSchema(new \GDS\Schema('SomeKindOfTest'));
     $obj_entity->test_property = 'Has value';
     $obj_entity->another_property = 'Another value';
     $this->assertEquals($obj_entity->getData(), ['test_property' => 'Has value', 'another_property' => 'Another value']);
 }
Пример #2
0
 /**
  * Ensure we can control index exclusion
  */
 public function testIndexExclusion()
 {
     $obj_schema = (new \GDS\Schema('Pub'))->addString('name', true)->addString('brewer', false);
     $obj_mapper = new \GDS\Mapper\RESTv1();
     $obj_mapper->setSchema($obj_schema);
     $obj_gds_entity = new \GDS\Entity();
     $obj_gds_entity->setSchema($obj_schema);
     $obj_gds_entity->setKind('Pub');
     $obj_gds_entity->name = 'The George';
     $obj_gds_entity->brewer = 'Old Brewery Limited';
     $obj_rest_entity = $obj_mapper->mapToGoogle($obj_gds_entity);
     $this->assertObjectHasAttribute('name', $obj_rest_entity->properties);
     $this->assertObjectHasAttribute('stringValue', $obj_rest_entity->properties->name);
     $this->assertObjectHasAttribute('excludeFromIndexes', $obj_rest_entity->properties->name);
     $this->assertFalse($obj_rest_entity->properties->name->excludeFromIndexes, 'name not indexed?');
     $this->assertObjectHasAttribute('brewer', $obj_rest_entity->properties);
     $this->assertObjectHasAttribute('stringValue', $obj_rest_entity->properties->brewer);
     $this->assertObjectHasAttribute('excludeFromIndexes', $obj_rest_entity->properties->brewer);
     $this->assertTrue($obj_rest_entity->properties->brewer->excludeFromIndexes, 'brewer indexed?');
 }