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

[Fix/Master] InputFilter/Input when merging was not using raw value #2620

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/Zend/InputFilter/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 tests/ZendTest/InputFilter/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]);
}
}