public function testAddField()
 {
     $fieldsData = ['id' => ['type' => new IntType()]];
     $config = new ObjectTypeConfig(['name' => 'UserType', 'fields' => $fieldsData]);
     $this->assertTrue($config->hasFields());
     $idField = new Field(['name' => 'id', 'type' => new IntType()]);
     $idField->getName();
     $nameField = new Field(['name' => 'name', 'type' => new StringType()]);
     $this->assertEquals(['id' => $idField], $config->getFields());
     $config->addField($nameField);
     $this->assertEquals(['id' => $idField, 'name' => $nameField], $config->getFields());
     $config->removeField('id');
     $this->assertEquals(['name' => $nameField], $config->getFields());
     $config->addFields(['id' => $idField]);
     $this->assertEquals(['name' => $nameField, 'id' => $idField], $config->getFields());
     $levelField = new Field(['name' => 'level', 'type' => new IntType()]);
     $config->addFields([$levelField]);
     $this->assertEquals(['name' => $nameField, 'id' => $idField, 'level' => $levelField], $config->getFields());
 }
Пример #2
0
 /**
  * @param ObjectTypeConfig $config
  *
  * @return mixed
  */
 public function build($config)
 {
     $config->addFields(['id' => new IdType(), 'url' => new StringType(), new ResizedField()]);
 }