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
103
104
105
106
|
<?php
class Html_helper_test extends CI_TestCase {
public function set_up()
{
$this->helper('html');
}
// ------------------------------------------------------------------------
public function test_br()
{
$this->assertEquals('<br /><br />', br(2));
}
// ------------------------------------------------------------------------
public function test_heading()
{
$this->assertEquals('<h1>foobar</h1>', heading('foobar'));
$this->assertEquals('<h2 class="bar">foobar</h2>', heading('foobar', 2, 'class="bar"'));
}
public function test_heading_array_attributes()
{
// Test array of attributes
$this->assertEquals('<h2 class="bar" id="foo">foobar</h2>', heading('foobar', 2, array('class' => 'bar', 'id' => 'foo')));
}
public function test_heading_object_attributes()
{
// Test array of attributes
$this->assertEquals('<h2 class="bar" id="foo">foobar</h2>', heading('foobar', 2, array('class' => 'bar', 'id' => 'foo')));
$test = new stdClass;
$test->class = "bar";
$test->id = "foo";
$this->assertEquals('<h2 class="bar" id="foo">foobar</h2>', heading('foobar', 2, $test));
}
// ------------------------------------------------------------------------
public function test_img()
{
$this->ci_set_config('base_url', 'http://localhost/');
$this->assertEquals('<img src="http://localhost/test" alt="" />', img("test"));
$this->assertEquals('<img src="data:foo/bar,baz" alt="" />', img("data:foo/bar,baz"));
$this->assertEquals('<img src="http://localhost/data://foo" alt="" />', img("data://foo"));
$this->assertEquals('<img src="//foo.bar/baz" alt="" />', img("//foo.bar/baz"));
$this->assertEquals('<img src="http://foo.bar/baz" alt="" />', img("http://foo.bar/baz"));
$this->assertEquals('<img src="https://foo.bar/baz" alt="" />', img("https://foo.bar/baz"));
$this->assertEquals('<img src="ftp://foo.bar/baz" alt="" />', img("ftp://foo.bar/baz"));
}
// ------------------------------------------------------------------------
public function test_Ul()
{
$expect = <<<EOH
<ul>
<li>foo</li>
<li>bar</li>
</ul>
EOH;
$expect = ltrim($expect);
$list = array('foo', 'bar');
$this->assertEquals(ltrim($expect), ul($list));
$expect = <<<EOH
<ul class="test">
<li>foo</li>
<li>bar</li>
</ul>
EOH;
$expect = ltrim($expect);
$this->assertEquals($expect, ul($list, 'class="test"'));
$this->assertEquals($expect, ul($list, array('class' => 'test')));
}
// ------------------------------------------------------------------------
public function test_NBS()
{
$this->assertEquals(' ', nbs(3));
}
// ------------------------------------------------------------------------
public function test_meta()
{
$this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo'));
$expect = "<meta name=\"foo\" content=\"\" />\n";
$this->assertEquals($expect, meta(array('name' => 'foo')));
}
}
|