TYPO3 CMS  TYPO3_6-2
JavaScriptEncoderTest.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $fixture = NULL;
28 
29  public function setUp() {
30  $this->fixture = new \TYPO3\CMS\Core\Encoder\JavaScriptEncoder();
31  }
32 
39  return array(
40  'Immune characters are returned as is' => array(
41  '._,',
42  '._,'
43  ),
44  'Alphanumerical characters are returned as is' => array(
45  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
46  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
47  ),
48  'Angel brackets and ampersand are encoded' => array(
49  '<>&',
50  '\\x3C\\x3E\\x26'
51  ),
52  'Quotes and slashes are encoded' => array(
53  '"\'\\/',
54  '\\x22\\x27\\x5C\\x2F'
55  ),
56  'Empty string stays empty' => array(
57  '',
58  ''
59  ),
60  'Exclamation mark and space are properly encoded' => array(
61  'Hello World!',
62  'Hello\\x20World\\x21'
63  ),
64  'Whitespaces are properly encoded' => array(
65  TAB . LF . CR . ' ',
66  '\\x09\\x0A\\x0D\\x20'
67  ),
68  'Null byte is properly encoded' => array(
69  chr(0),
70  '\\x00'
71  ),
72  'Umlauts are properly encoded' => array(
73  'ÜüÖöÄä',
74  '\\xDC\\xFC\\xD6\\xF6\\xC4\\xE4'
75  )
76  );
77  }
78 
85  public function encodeEncodesCorrectly($input, $expected) {
86  $this->assertSame($expected, $this->fixture->encode($input));
87  }
88 
89 }