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

BaseInputFilter::populate() calls resetValue() for missing arrayinputs #72

Merged
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 0 additions & 5 deletions src/BaseInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,6 @@ protected function populate()
continue;
}

if ($input instanceof ArrayInput) {
$input->setValue([]);
continue;
}

if ($input instanceof Input) {
$input->resetValue();
continue;
Expand Down
12 changes: 10 additions & 2 deletions test/BaseInputFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand Down