summaryrefslogtreecommitdiff
path: root/tests/Framework/Html.php
blob: d9466e60144bca5e1de94323aebcc94a27ef631a (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php

/**
 * Test class to test rcube_html class
 *
 * @package Tests
 */
class Framework_Html extends PHPUnit_Framework_TestCase
{

    /**
     * Class constructor
     */
    function test_class()
    {
        $object = new html;

        $this->assertInstanceOf('html', $object, "Class constructor");
    }

    /**
     * Data for test_attrib_string()
     */
    function data_attrib_string()
    {
        return array(
            array(
                array(), null, '',
            ),
            array(
                array('test' => 'test'), null, ' test="test"',
            ),
            array(
                array('test' => 'test'), array('test'), ' test="test"',
            ),
            array(
                array('test' => 'test'), array('other'), '',
            ),
            array(
                array('checked' => true), null, ' checked="checked"',
            ),
            array(
                array('checked' => ''), null, '',
            ),
            array(
                array('onclick' => ''), null, '',
            ),
            array(
                array('size' => 5), null, ' size="5"',
            ),
            array(
                array('size' => 'test'), null, '',
            ),
            array(
                array('data-test' => 'test'), null, ' data-test="test"',
            ),
            array(
                array('data-test' => 'test'), array('other'), '',
            ),
            array(
                array('data-test' => 'test'), array('data-test'), ' data-test="test"',
            ),
            array(
                array('data-test' => 'test'), array('data-*'), ' data-test="test"',
            ),
        );
    }

    /**
     * Test for attrib_string()
     * @dataProvider data_attrib_string
     */
    function test_attrib_string($arg1, $arg2, $result)
    {
        $this->assertEquals(html::attrib_string($arg1, $arg2), $result);
    }

    /**
     * Data for test_quote()
     */
    function data_quote()
    {
        return array(
            array('abc', 'abc'),
            array('?', '?'),
            array('"', '&quot;'),
            array('<', '&lt;'),
            array('>', '&gt;'),
            array('&', '&amp;'),
            array('&amp;', '&amp;amp;'),
        );
    }

    /**
     * Test for quote()
     * @dataProvider data_quote
     */
    function test_quote($str, $result)
    {
        $this->assertEquals(html::quote($str), $result);
    }
}