function it_knows_if_field_with_given_name_already_exists(Field $field) { $field->getName()->willReturn('enabled'); $this->addField($field); $this->hasField('enabled')->shouldReturn(true); $this->hasField('parent')->shouldReturn(false); }
/** * @param Field $field */ public function addField(Field $field) { $name = $field->getName(); if ($this->hasField($name)) { throw new \InvalidArgumentException(sprintf('Field "%s" already exists.', $name)); } $this->fields[$name] = $field; }