Exemple #1
0
 public function testConstruct()
 {
     $name = 'test';
     $label = 'My Awesome Test';
     $object = new Field($name, $label);
     $this->assertEquals($name, $object->getName());
     $this->assertEquals($label, $object->getLabel());
 }
Exemple #2
0
 /**
  * Adds a new field to the validation object
  *
  * @param string|FieldInterface $field
  * @param string                $label Field name to use in messages, set to null to use $field
  *
  * @return $this
  *
  * @throws InvalidArgumentException
  *
  * @since 2.0
  */
 public function addField($field, $label = null)
 {
     if (is_string($field)) {
         $field = new Field($field, $label);
     }
     if (!$field instanceof FieldInterface) {
         throw new InvalidArgumentException('VAL-007: Only FieldInterfaces can be added as a field.');
     }
     $this->fields[$field->getName()] = $field;
     $this->lastAddedField = $field;
     return $this;
 }