public function testAddErrorMapsErrorsOntoFieldsInVirtualGroups() { $error = new FieldError('Message'); // path is expected to point at "address" $expectedPath = new PropertyPath('address'); $expectedPathIterator = $expectedPath->getIterator(); $field = $this->createMockField('address'); $field->expects($this->any())->method('getPropertyPath')->will($this->returnValue(new PropertyPath('address'))); $field->expects($this->once())->method('addError')->with($this->equalTo($error), $this->equalTo($expectedPathIterator), $this->equalTo(FieldGroup::DATA_ERROR)); $group = new TestFieldGroup('author'); $nestedGroup = new TestFieldGroup('nested', array('virtual' => true)); $nestedGroup->add($field); $group->add($nestedGroup); $path = new PropertyPath('address'); $group->addError($error, $path->getIterator(), FieldGroup::DATA_ERROR); }
public function testAddErrorMapsErrorsOntoFieldsInAnonymousGroups() { // path is expected to point at "address" $expectedPath = new PropertyPath('address'); $expectedPathIterator = $expectedPath->getIterator(); $field = $this->createMockField('address'); $field->expects($this->any())->method('getPropertyPath')->will($this->returnValue(new PropertyPath('address'))); $field->expects($this->once())->method('addError')->with($this->equalTo('Message'), array(), $this->equalTo($expectedPathIterator), $this->equalTo(FieldGroup::DATA_ERROR)); $group = new TestFieldGroup('author'); $group2 = new TestFieldGroup('anonymous', array('property_path' => null)); $group2->add($field); $group->add($group2); $path = new PropertyPath('address'); $group->addError('Message', array(), $path->getIterator(), FieldGroup::DATA_ERROR); }