Merge branch 'QA_3_3'
[phpmyadmin/dkf.git] / test / PMA_escapeJsString_test.php
blob6b54cea65dcf0492f3c58c81f1660148f22a2118
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for javascript escaping.
6 * @package phpMyAdmin-test
7 * @version $Id$
8 */
10 /**
11 * Tests core.
13 require_once 'PHPUnit/Framework.php';
15 /**
16 * Include to test.
18 require_once './libraries/js_escape.lib.php';
20 /**
21 * Test java script escaping.
23 * @package phpMyAdmin-test
25 class PMA_escapeJsString_test extends PHPUnit_Framework_TestCase
27 public function testEscape_1()
29 $this->assertEquals('\\\';', PMA_escapeJsString('\';'));
32 public function testEscape_2()
34 $this->assertEquals('\r\n\\\'<scrIpt></\' + \'script>', PMA_escapeJsString("\r\n'<scrIpt></sCRIPT>"));
37 public function testEscape_3()
39 $this->assertEquals('\\\';[XSS]', PMA_escapeJsString('\';[XSS]'));
42 public function testEscape_4()
44 $this->assertEquals('</\' + \'script></head><body>[HTML]', PMA_escapeJsString('</SCRIPT></head><body>[HTML]'));
47 public function testEscape_5()
49 $this->assertEquals('"\\\'\\\\\\\'"', PMA_escapeJsString('"\'\\\'"'));
52 public function testEscape_6()
54 $this->assertEquals("\\\\\'\'\'\'\'\'\'\'\'\'\'\'\\\\", PMA_escapeJsString("\\''''''''''''\\"));