فهرست منبع

Resolving issue https://github.com/sonata-project/sandbox/issues/89

Hugo Briand 11 سال پیش
والد
کامیت
7f66428d72
2فایلهای تغییر یافته به همراه28 افزوده شده و 1 حذف شده
  1. 3 1
      Filter/Filter.php
  2. 25 0
      Tests/Filter/FilterTest.php

+ 3 - 1
Filter/Filter.php

@@ -199,7 +199,9 @@ abstract class Filter implements FilterInterface
     {
         $values = $this->getValue();
 
-        return !empty($values['value']);
+        return isset($values['value'])
+            && false !== $values['value']
+            && "" !== $values['value'];
     }
 
     /**

+ 25 - 0
Tests/Filter/FilterTest.php

@@ -102,4 +102,29 @@ class FilterTest extends \PHPUnit_Framework_TestCase
 
         $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")),
+        );
+    }
 }