7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Filter
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
27 require_once dirname(__FILE__
) . '/../../TestHelper.php';
30 * @see Zend_Filter_StringToLower
32 require_once 'Zend/Filter/StringToLower.php';
37 * @package Zend_Filter
38 * @subpackage UnitTests
39 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
40 * @license http://framework.zend.com/license/new-bsd New BSD License
43 class Zend_Filter_StringToLowerTest
extends PHPUnit_Framework_TestCase
46 * Zend_Filter_StringToLower object
48 * @var Zend_Filter_StringToLower
53 * Creates a new Zend_Filter_StringToLower object for each test method
57 public function setUp()
59 $this->_filter
= new Zend_Filter_StringToLower();
63 * Ensures that the filter follows expected behavior
67 public function testBasic()
69 $valuesExpected = array(
75 foreach ($valuesExpected as $input => $output) {
76 $this->assertEquals($output, $this->_filter
->filter($input));
81 * Ensures that the filter follows expected behavior with
86 public function testWithEncoding()
88 $valuesExpected = array(
95 $this->_filter
->setEncoding('UTF-8');
96 foreach ($valuesExpected as $input => $output) {
97 $this->assertEquals($output, $this->_filter
->filter($input));
99 } catch (Zend_Filter_Exception
$e) {
100 $this->assertContains('mbstring is required', $e->getMessage());
107 public function testFalseEncoding()
109 if (!function_exists('mb_strtolower')) {
110 $this->markTestSkipped('mbstring required');
114 $this->_filter
->setEncoding('aaaaa');
116 } catch (Zend_Filter_Exception
$e) {
117 $this->assertContains('is not supported', $e->getMessage());
124 public function testInitiationWithEncoding()
126 $valuesExpected = array(
133 $filter = new Zend_Filter_StringToLower(array('encoding' => 'UTF-8'));
134 foreach ($valuesExpected as $input => $output) {
135 $this->assertEquals($output, $filter->filter($input));
137 } catch (Zend_Filter_Exception
$e) {
138 $this->assertContains('mbstring is required', $e->getMessage());
145 public function testCaseInsensitiveEncoding()
147 $valuesExpected = array(
154 $this->_filter
->setEncoding('UTF-8');
155 foreach ($valuesExpected as $input => $output) {
156 $this->assertEquals($output, $this->_filter
->filter($input));
159 $this->_filter
->setEncoding('utf-8');
160 foreach ($valuesExpected as $input => $output) {
161 $this->assertEquals($output, $this->_filter
->filter($input));
164 $this->_filter
->setEncoding('UtF-8');
165 foreach ($valuesExpected as $input => $output) {
166 $this->assertEquals($output, $this->_filter
->filter($input));
168 } catch (Zend_Filter_Exception
$e) {
169 $this->assertContains('mbstring is required', $e->getMessage());