2 namespace TYPO3\CMS\Core\Tests\Unit\Encoder
;
4 /***************************************************************
7 * (c) 2012 Helmut Hummel <helmut.hummel@typo3.org>
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
28 * Test cases for TYPO3\CMS\Core\Encoder\JavaScriptEncoder.
32 * @author Helmut Hummel <helmut.hummel@typo3.org>
34 class JavaScriptEncoderTest
extends \Tx_Phpunit_TestCase
{
37 * @var \TYPO3\CMS\Core\Encoder\JavaScriptEncoder
39 protected $fixture = NULL;
41 public function setUp() {
42 $this->fixture
= new \TYPO3\CMS\Core\Encoder\
JavaScriptEncoder();
45 public function tearDown() {
46 unset($this->fixture
);
50 * Data provider for encodeEncodesCorrectly.
54 public function encodeEncodesCorrectlyDataProvider() {
56 'Immune characters are returned as is' => array(
60 'Alphanumerical characters are returned as is' => array(
61 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
62 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
64 'Angel brackets and ampersand are encoded' => array(
68 'Quotes and slashes are encoded' => array(
70 '\\x22\\x27\\x5C\\x2F'
72 'Empty string stays empty' => array(
76 'Exclamation mark and space are properly encoded' => array(
78 'Hello\\x20World\\x21'
80 'Whitespaces are properly encoded' => array(
81 ((TAB
. LF
) . CR
) . ' ',
82 '\\x09\\x0A\\x0D\\x20'
84 'Null byte is properly encoded' => array(
88 'Umlauts are properly encoded' => array(
90 '\\xDC\\xFC\\xD6\\xF6\\xC4\\xE4'
97 * @param string $input
98 * @param string $expected
99 * @dataProvider encodeEncodesCorrectlyDataProvider
101 public function encodeEncodesCorrectly($input, $expected) {
102 $this->assertSame($expected, $this->fixture
->encode($input));