Beispiel #1
0
 public function testApimap()
 {
     $apimap = json_decode($this->map->getApimap());
     $this->assertTrue(is_object($apimap));
     $this->assertObjectHasAttribute('data', $apimap);
     $this->assertTrue(is_array($apimap->data));
     $data = $apimap->data[59];
     $this->assertObjectHasAttribute('type', $data);
     $this->assertEquals('collections', $data->type);
     $this->assertObjectHasAttribute('id', $data);
     $this->assertEquals('units', $data->id);
     $this->assertObjectHasAttribute('attributes', $data);
     $this->assertObjectHasAttribute('name', $data->attributes);
     $this->assertEquals('units', $data->attributes->name);
     $this->assertObjectHasAttribute('fields', $data->attributes);
     $this->assertCount(6, $data->attributes->fields);
     $attributes = (array) $data->attributes;
     $this->assertArrayHasKey('only-for-relationships', $attributes);
     $this->assertNull($attributes['only-for-relationships']);
     $this->assertArrayHasKey('is-virtual', $attributes);
     $this->assertNull($attributes['is-virtual']);
     $this->assertArrayHasKey('is-read-only', $attributes);
     $this->assertFalse($attributes['is-read-only']);
     $this->assertArrayHasKey('is-searchable', $attributes);
     $this->assertTrue($attributes['is-searchable']);
     $this->assertObjectHasAttribute('links', $data);
     $this->assertObjectHasAttribute('self', $data->links);
     $this->assertEquals('/collections/units', $data->links->self);
     $this->assertObjectHasAttribute('field', $data->attributes->fields[0]);
     $this->assertEquals('id', $data->attributes->fields[0]->field);
     $this->assertEquals('Number', $data->attributes->fields[0]->type);
     $this->assertObjectNotHasAttribute('reference', $data->attributes->fields[0]);
     $this->assertObjectNotHasAttribute('inverseOf', $data->attributes->fields[0]);
     $this->assertEquals('translations', $data->attributes->fields[4]->field);
     $this->assertTrue(is_array($data->attributes->fields[4]->type));
     $this->assertEquals('Number', $data->attributes->fields[4]->type[0]);
     $this->assertObjectHasAttribute('reference', $data->attributes->fields[4]);
     $this->assertEquals('unit_translation.id', $data->attributes->fields[4]->reference);
     $this->assertObjectNotHasAttribute('inverseOf', $data->attributes->fields[4]);
     $data = $apimap->data[77];
     $this->assertEquals('user', $data->attributes->fields[13]->field);
     $this->assertEquals('Number', $data->attributes->fields[13]->type);
     $this->assertObjectHasAttribute('reference', $data->attributes->fields[13]);
     $this->assertEquals('users.id', $data->attributes->fields[13]->reference);
     $this->assertObjectHasAttribute('inverseOf', $data->attributes->fields[13]);
     $this->assertEquals('company', $data->attributes->fields[13]->inverseOf);
 }
 public function getApimap()
 {
     $map = new Map($this->getCollections(), $this->getApimapMeta());
     return $map->getApimap();
 }