blob: 28974b0f81426cac6741cb9f867501c90458d33f [file] [log] [blame]
Greg Akerb5679472011-04-21 14:34:31 -05001<?php
2
Taufan Adityae1dc9ea2012-03-28 16:49:49 +07003class Html_helper_test extends CI_TestCase {
Greg Akerb5679472011-04-21 14:34:31 -05004
Taufan Adityae1dc9ea2012-03-28 16:49:49 +07005 public function set_up()
6 {
7 $this->helper('html');
8 }
Eric Barnes68286a42011-04-21 22:00:33 -04009
10 // ------------------------------------------------------------------------
11
12 public function test_br()
13 {
14 $this->assertEquals('<br /><br />', br(2));
15 }
16
17 // ------------------------------------------------------------------------
18
19 public function test_heading()
Greg Akerb5679472011-04-21 14:34:31 -050020 {
21 $this->assertEquals('<h1>foobar</h1>', heading('foobar'));
Eric Barnes68286a42011-04-21 22:00:33 -040022 $this->assertEquals('<h2 class="bar">foobar</h2>', heading('foobar', 2, 'class="bar"'));
Greg Akerb5679472011-04-21 14:34:31 -050023 }
24
25 // ------------------------------------------------------------------------
26
Eric Barnes68286a42011-04-21 22:00:33 -040027 public function test_Ul()
Greg Akerb5679472011-04-21 14:34:31 -050028 {
29 $expect = <<<EOH
30<ul>
31 <li>foo</li>
32 <li>bar</li>
33</ul>
34
35EOH;
36
37 $expect = ltrim($expect);
38
39 $list = array('foo', 'bar');
40
41 $this->assertEquals($expect, ul($list));
42
43
44 $expect = <<<EOH
45<ul class="test">
46 <li>foo</li>
47 <li>bar</li>
48</ul>
49
50EOH;
51
52 $expect = ltrim($expect);
53
54 $list = array('foo', 'bar');
55
Greg Aker92ff07e2011-08-20 16:57:48 -050056 $this->assertEquals($expect, ul($list, 'class="test"'));
Greg Akerb5679472011-04-21 14:34:31 -050057
58 $this->assertEquals($expect, ul($list, array('class' => 'test')));
59 }
60
61 // ------------------------------------------------------------------------
62
Eric Barnes68286a42011-04-21 22:00:33 -040063 public function test_NBS()
Greg Akerb5679472011-04-21 14:34:31 -050064 {
65 $this->assertEquals('&nbsp;&nbsp;&nbsp;', nbs(3));
66 }
67
68 // ------------------------------------------------------------------------
69
Eric Barnes68286a42011-04-21 22:00:33 -040070 public function test_meta()
Greg Akerb5679472011-04-21 14:34:31 -050071 {
72 $this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo'));
73
74 $expect = "<meta name=\"foo\" content=\"\" />\n";
75
76 $this->assertEquals($expect, meta(array('name' => 'foo')));
77
78 }
79
80}