Skip to content

Commit

Permalink
Resolving issue sonata-project/sandbox#89
Browse files Browse the repository at this point in the history
  • Loading branch information
Bladrak committed Dec 14, 2013
1 parent adfcd06 commit 7f66428
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Filter/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ public function isActive()
{
$values = $this->getValue();

return !empty($values['value']);
return isset($values['value'])
&& false !== $values['value']
&& "" !== $values['value'];
}

/**
Expand Down
25 changes: 25 additions & 0 deletions Tests/Filter/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,29 @@ public function testExceptionOnNonDefinedFieldName()

$filter->getFieldName();
}

/**
* @dataProvider isActiveData
*
* @param $expected
* @param $value
*/
public function testIsActive($expected, $value)
{
$filter = new FilterTest_Filter;
$filter->setValue($value);

$this->assertEquals($expected, $filter->isActive());
}

public function isActiveData()
{
return array(
array(false, array()),
array(false, array('value' => null)),
array(false, array('value' => "")),
array(false, array('value' => false)),
array(true, array('value' => "active")),
);
}
}

0 comments on commit 7f66428

Please sign in to comment.