ZF-8222: format class name for class checks
[zend.git] / tests / Zend / Filter / StringToLowerTest.php
blob8ec787d7d881f8f1d7527a64b263b130407308d4
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
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
20 * @version $Id$
24 /**
25 * Test helper
27 require_once dirname(__FILE__) . '/../../TestHelper.php';
29 /**
30 * @see Zend_Filter_StringToLower
32 require_once 'Zend/Filter/StringToLower.php';
35 /**
36 * @category Zend
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
41 * @group Zend_Filter
43 class Zend_Filter_StringToLowerTest extends PHPUnit_Framework_TestCase
45 /**
46 * Zend_Filter_StringToLower object
48 * @var Zend_Filter_StringToLower
50 protected $_filter;
52 /**
53 * Creates a new Zend_Filter_StringToLower object for each test method
55 * @return void
57 public function setUp()
59 $this->_filter = new Zend_Filter_StringToLower();
62 /**
63 * Ensures that the filter follows expected behavior
65 * @return void
67 public function testBasic()
69 $valuesExpected = array(
70 'string' => 'string',
71 'aBc1@3' => 'abc1@3',
72 'A b C' => 'a b c'
75 foreach ($valuesExpected as $input => $output) {
76 $this->assertEquals($output, $this->_filter->filter($input));
80 /**
81 * Ensures that the filter follows expected behavior with
82 * specified encoding
84 * @return void
86 public function testWithEncoding()
88 $valuesExpected = array(
89 'Ü' => 'ü',
90 'Ñ' => 'ñ',
91 'ÜÑ123' => 'üñ123'
94 try {
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());
105 * @return void
107 public function testFalseEncoding()
109 if (!function_exists('mb_strtolower')) {
110 $this->markTestSkipped('mbstring required');
113 try {
114 $this->_filter->setEncoding('aaaaa');
115 $this->fail();
116 } catch (Zend_Filter_Exception $e) {
117 $this->assertContains('is not supported', $e->getMessage());
122 * @ZF-8989
124 public function testInitiationWithEncoding()
126 $valuesExpected = array(
127 'Ü' => 'ü',
128 'Ñ' => 'ñ',
129 'ÜÑ123' => 'üñ123'
132 try {
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());
143 * @ZF-9058
145 public function testCaseInsensitiveEncoding()
147 $valuesExpected = array(
148 'Ü' => 'ü',
149 'Ñ' => 'ñ',
150 'ÜÑ123' => 'üñ123'
153 try {
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());