Browse Source

[ZF-10691] Zend_Filter

- Fixed allows assign chartlist in constructor.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23396 44c647ce-9c0f-0410-b52a-842ac1e357ba
ramon 15 years ago
parent
commit
9823285c0c
2 changed files with 24 additions and 6 deletions
  1. 5 5
      library/Zend/Filter/StringTrim.php
  2. 19 1
      tests/Zend/Filter/StringTrimTest.php

+ 5 - 5
library/Zend/Filter/StringTrim.php

@@ -45,14 +45,14 @@ class Zend_Filter_StringTrim implements Zend_Filter_Interface
     /**
      * Sets filter options
      *
-     * @param  string|array|Zend_Config $charList
+     * @param  string|array|Zend_Config $options
      * @return void
      */
-    public function __construct($charList = null)
+    public function __construct($options = null)
     {
-        if ($charList instanceof Zend_Config) {
-            $charList = $charList->toArray();
-        } else if (!is_array($charList)) {
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        } else if (!is_array($options)) {
             $options          = func_get_args();
             $temp['charlist'] = array_shift($options);
             $options          = $temp;

+ 19 - 1
tests/Zend/Filter/StringTrimTest.php

@@ -120,4 +120,22 @@ class Zend_Filter_StringTrimTest extends PHPUnit_Framework_TestCase
     public function testZF7902()
     {
         $this->assertEquals('/', $this->_filter->filter('/'));
-    }}
+    }
+
+    /**
+     * @group ZF-10691
+     */
+    public function testSetParamCharListToConstructor()
+    {
+        require_once 'Zend/Config.php';
+        $config = new Zend_Config(array('charlist' => '&'));
+        $filter = new Zend_Filter_StringTrim($config);
+        $this->assertEquals('&', $filter->getCharList());
+
+        $filter = new Zend_Filter_StringTrim(array('charlist' => '&'));
+        $this->assertEquals('&', $filter->getCharList());
+
+        $filter = new Zend_Filter_StringTrim('&');
+        $this->assertEquals('&', $filter->getCharList());
+    }
+}