public function testFieldAddsThreeFieldsToType()
 {
     $created_by_id = new ActionByField('created_by_id', 'User', 'IdentifiedVisitor');
     $fields = $created_by_id->getFields();
     $this->assertInternalType('array', $fields);
     $this->assertCount(3, $fields);
     $this->assertInstanceOf(IntegerField::class, $fields[0]);
     $this->assertInstanceOf(StringField::class, $fields[1]);
     $this->assertInstanceOf(EmailField::class, $fields[2]);
     $type = (new Type('chapters'))->addField($created_by_id);
     $this->assertArrayHasKey('created_by_id', $type->getAllFields());
     $this->assertInstanceOf(IntegerField::class, $type->getAllFields()['created_by_id']);
     $this->assertArrayHasKey('created_by_name', $type->getAllFields());
     $this->assertInstanceOf(StringField::class, $type->getAllFields()['created_by_name']);
     $this->assertArrayHasKey('created_by_email', $type->getAllFields());
     $this->assertInstanceOf(StringField::class, $type->getAllFields()['created_by_email']);
 }
 /**
  * {@inheritdoc}
  */
 public function onAddedToType(TypeInterface &$type)
 {
     parent::onAddedToType($type);
     if ($this->isRequired()) {
         $type->addTrait(CreatedByRequiredInterface::class);
     } else {
         $type->addTrait(CreatedByOptionalInterface::class);
     }
 }