Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Oct 8, 2018
1 parent 07d634f commit 10fa0d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Model/Filter/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ protected function passedValue()
return $this->getConfig('multiValue') ? $value : null;
}

if ($this->getConfig('multiValue') && $this->getConfig('multiValueSeparator')) {
if ($this->getConfig('multiValueSeparator')) {
return explode($this->getConfig('multiValueSeparator'), $value);
}

Expand Down
19 changes: 16 additions & 3 deletions tests/TestCase/Model/Filter/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,27 @@ public function testValueMultiValueSeparator()
['defaultValue' => 'default']
);

$filter->setConfig('multiValue', true);
$filter->setConfig('multiValueSeparator', '|');

$filter->setArgs(['field' => 'value1|value2']);
$this->assertEquals(['value1', 'value2'], $filter->value());
}

$filter->setArgs(['field' => ['value1', 'value2']]);
$this->assertEquals(['value1', 'value2'], $filter->value());
/**
* @return void
*/
public function testValueMultiValueSeparatorInvalid()
{
$filter = new TestFilter(
'field',
$this->Manager,
['defaultValue' => 'default']
);

$filter->setConfig('multiValue', true);

$filter->setArgs(['field' => 'value1|value2']);
$this->assertEquals('value1|value2', $filter->value());
}

/**
Expand Down

0 comments on commit 10fa0d5

Please sign in to comment.