diff --git a/CHANGELOG.md b/CHANGELOG.md index cee927f0..e2383f3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- Nothing. +- `ArrayInput::hasValue()` returned `true` for inputs that didn't get a value via `BaseInputFilter::setData()` ## 2.5.5 - 2015-09-03 diff --git a/src/BaseInputFilter.php b/src/BaseInputFilter.php index 1fea9709..5ccfdf44 100644 --- a/src/BaseInputFilter.php +++ b/src/BaseInputFilter.php @@ -512,11 +512,6 @@ protected function populate() continue; } - if ($input instanceof ArrayInput) { - $input->setValue([]); - continue; - } - if ($input instanceof Input) { $input->resetValue(); continue; diff --git a/test/BaseInputFilterTest.php b/test/BaseInputFilterTest.php index 692adc93..a56916f7 100644 --- a/test/BaseInputFilterTest.php +++ b/test/BaseInputFilterTest.php @@ -565,8 +565,7 @@ public function testPopulateSupportsArrayInputEvenIfDataMissing() $arrayInput = $this->getMock(ArrayInput::class); $arrayInput ->expects($this->once()) - ->method('setValue') - ->with([]); + ->method('resetValue'); $filter = $this->inputFilter; $filter->add($arrayInput, 'arrayInput'); @@ -598,6 +597,15 @@ public function testMerge() ); } + public function testHasValueIsFalseIfNoValueWasProvided() + { + $inputFilter = new BaseInputFilter(); + $inputFilter->add(new ArrayInput(), 'foo'); + + $inputFilter->setData([]); + $this->assertFalse($inputFilter->get('foo')->hasValue()); + } + public function addMethodArgumentsProvider() { $inputTypes = $this->inputProvider();