Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PMA_escapeJsString_test.php « libraries « test - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 96ad8e25ab75365bcab6139d8a07bea941850b01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Test for javascript escaping.
 *
 * @package PhpMyAdmin-test
 */

/*
 * Include to test.
 */
require_once 'libraries/js_escape.lib.php';

/**
 * Test for javascript escaping.
 *
 * @package PhpMyAdmin-test
 */
class PMA_EscapeJsString_Test extends PHPUnit_Framework_TestCase
{
    /**
     * PMA_escapeJsString tests
     *
     * @param string $target expected output
     * @param string $source string to be escaped
     *
     * @return void
     * @dataProvider escapeDataProvider
     */
    public function testEscape($target, $source)
    {
        $this->assertEquals($target, PMA_escapeJsString($source));
    }

    /**
     * Data provider for testEscape
     *
     * @return array data for testEscape test case
     */
    public function escapeDataProvider()
    {
        return array(
            array('\\\';', '\';'),
            array('\r\n\\\'<scrIpt></\' + \'script>', "\r\n'<scrIpt></sCRIPT>"),
            array('\\\';[XSS]', '\';[XSS]'),
            array(
                '</\' + \'script></head><body>[HTML]',
                '</SCRIPT></head><body>[HTML]'
            ),
            array('\"\\\'\\\\\\\'\"', '"\'\\\'"'),
            array("\\\\\'\'\'\'\'\'\'\'\'\'\'\'\\\\", "\\''''''''''''\\")
        );
    }
}
?>