Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2620' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function merge(InputInterface $input)
$this->setErrorMessage($input->getErrorMessage());
$this->setName($input->getName());
$this->setRequired($input->isRequired());
$this->setValue($input->getValue());
$this->setValue($input->getRawValue());

$filterChain = $input->getFilterChain();
$this->getFilterChain()->merge($filterChain);
Expand Down
25 changes: 25 additions & 0 deletions test/InputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,29 @@ public function testRequiredNotEmptyValidatorNotAddedWhenOneExists()
$this->assertEquals(1, count($validators));
$this->assertEquals($notEmptyMock, $validators[0]['instance']);
}

public function testMerge()
{
$input = new Input('foo');
$input->setValue(' 123 ');
$filter = new Filter\StringTrim();
$input->getFilterChain()->attach($filter);
$validator = new Validator\Digits();
$input->getValidatorChain()->addValidator($validator);

$input2 = new Input('bar');
$input2->merge($input);
$validatorChain = $input->getValidatorChain();
$filterChain = $input->getFilterChain();

$this->assertEquals(' 123 ', $input2->getRawValue());
$this->assertEquals(1, $validatorChain->count());
$this->assertEquals(1, $filterChain->count());

$validators = $validatorChain->getValidators();
$this->assertInstanceOf('Zend\Validator\Digits', $validators[0]['instance']);

$filters = $filterChain->getFilters()->toArray();
$this->assertInstanceOf('Zend\Filter\StringTrim', $filters[0]);
}
}

0 comments on commit f0e4074

Please sign in to comment.