Преглед на файлове

[ZF-8989] Zend_Filter:

- fix constructor

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20717 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas преди 16 години
родител
ревизия
b9649dda1c

+ 1 - 1
library/Zend/Filter/StringToLower.php

@@ -58,7 +58,7 @@ class Zend_Filter_StringToLower implements Zend_Filter_Interface
         }
         }
 
 
         if (array_key_exists('encoding', $options)) {
         if (array_key_exists('encoding', $options)) {
-            $this->setEncoding($options);
+            $this->setEncoding($options['encoding']);
         }
         }
     }
     }
 
 

+ 1 - 1
library/Zend/Filter/StringToUpper.php

@@ -58,7 +58,7 @@ class Zend_Filter_StringToUpper implements Zend_Filter_Interface
         }
         }
 
 
         if (array_key_exists('encoding', $options)) {
         if (array_key_exists('encoding', $options)) {
-            $this->setEncoding($options);
+            $this->setEncoding($options['encoding']);
         }
         }
     }
     }
 
 

+ 21 - 0
tests/Zend/Filter/StringToLowerTest.php

@@ -117,4 +117,25 @@ class Zend_Filter_StringToLowerTest extends PHPUnit_Framework_TestCase
             $this->assertContains('is not supported', $e->getMessage());
             $this->assertContains('is not supported', $e->getMessage());
         }
         }
     }
     }
+
+    /**
+     * @ZF-8989
+     */
+    public function testInitiationWithEncoding()
+    {
+        $valuesExpected = array(
+            'Ü'     => 'ü',
+            'Ñ'     => 'ñ',
+            'ÜÑ123' => 'üñ123'
+        );
+
+        try {
+            $filter = new Zend_Filter_StringToLower(array('encoding' => 'UTF-8'));
+            foreach ($valuesExpected as $input => $output) {
+                $this->assertEquals($output, $filter->filter($input));
+            }
+        } catch (Zend_Filter_Exception $e) {
+            $this->assertContains('mbstring is required', $e->getMessage());
+        }
+    }
 }
 }

+ 21 - 0
tests/Zend/Filter/StringToUpperTest.php

@@ -117,4 +117,25 @@ class Zend_Filter_StringToUpperTest extends PHPUnit_Framework_TestCase
             $this->assertContains('is not supported', $e->getMessage());
             $this->assertContains('is not supported', $e->getMessage());
         }
         }
     }
     }
+
+    /**
+     * @ZF-8989
+     */
+    public function testInitiationWithEncoding()
+    {
+        $valuesExpected = array(
+            'ü'     => 'Ü',
+            'ñ'     => 'Ñ',
+            'üñ123' => 'ÜÑ123'
+        );
+
+        try {
+            $filter = new Zend_Filter_StringToUpper(array('encoding' => 'UTF-8'));
+            foreach ($valuesExpected as $input => $output) {
+                $this->assertEquals($output, $filter->filter($input));
+            }
+        } catch (Zend_Filter_Exception $e) {
+            $this->assertContains('mbstring is required', $e->getMessage());
+        }
+    }
 }
 }