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

Commit

Permalink
Merge branch 'functionality/WriterPluginManager' of github.com:jdolie…
Browse files Browse the repository at this point in the history
…slager/zf2 into functionality/WriterPluginManager
  • Loading branch information
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -8,7 +8,7 @@
],
"autoload": {
"psr-4": {
"Zend\\InputFilter": "src/"
"Zend\\InputFilter\\": "src/"
}
},
"require": {
Expand Down
2 changes: 1 addition & 1 deletion src/Input.php
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
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 e730f97

Please sign in to comment.