Aleksander Machniak
2014-04-28 7e3af82c4f7081d4ae0af9d7eea91d29f20bfd73
commit | author | age
b37954 1 <?php
AM 2
3 /**
4  * Test class to test rcube_html class
5  *
6  * @package Tests
7  */
8 class Framework_Html extends PHPUnit_Framework_TestCase
9 {
10
11     /**
12      * Class constructor
13      */
14     function test_class()
15     {
16         $object = new html;
17
18         $this->assertInstanceOf('html', $object, "Class constructor");
19     }
20
21     /**
a4cd91 22      * Data for test_attrib_string()
AM 23      */
24     function data_attrib_string()
25     {
26         return array(
27             array(
28                 array(), null, '',
29             ),
30             array(
31                 array('test' => 'test'), null, ' test="test"',
32             ),
33             array(
34                 array('test' => 'test'), array('test'), ' test="test"',
35             ),
36             array(
37                 array('test' => 'test'), array('other'), '',
38             ),
39             array(
40                 array('checked' => true), null, ' checked="checked"',
41             ),
42             array(
43                 array('checked' => ''), null, '',
44             ),
45             array(
46                 array('onclick' => ''), null, '',
47             ),
48             array(
49                 array('size' => 5), null, ' size="5"',
50             ),
51             array(
52                 array('size' => 'test'), null, '',
53             ),
54             array(
55                 array('data-test' => 'test'), null, ' data-test="test"',
56             ),
57             array(
58                 array('data-test' => 'test'), array('other'), '',
59             ),
60             array(
61                 array('data-test' => 'test'), array('data-test'), ' data-test="test"',
62             ),
63             array(
64                 array('data-test' => 'test'), array('data-*'), ' data-test="test"',
65             ),
66         );
67     }
68
69     /**
70      * Test for attrib_string()
71      * @dataProvider data_attrib_string
72      */
73     function test_attrib_string($arg1, $arg2, $result)
74     {
75         $this->assertEquals(html::attrib_string($arg1, $arg2), $result);
76     }
77
78     /**
b37954 79      * Data for test_quote()
AM 80      */
81     function data_quote()
82     {
83         return array(
84             array('abc', 'abc'),
85             array('?', '?'),
86             array('"', '&quot;'),
87             array('<', '&lt;'),
88             array('>', '&gt;'),
89             array('&', '&amp;'),
90             array('&amp;', '&amp;amp;'),
91         );
92     }
93
94     /**
95      * Test for quote()
96      * @dataProvider data_quote
97      */
98     function test_quote($str, $result)
99     {
100         $this->assertEquals(html::quote($str), $result);
101     }
102 }