blob: 9a7bb48bfad9a66a152a932a744fba3b2d5669e3 [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 }
Andrey Andreev99b782d2012-06-09 22:24:46 +03009
Eric Barnes68286a42011-04-21 22:00:33 -040010 // ------------------------------------------------------------------------
Andrey Andreev99b782d2012-06-09 22:24:46 +030011
Eric Barnes68286a42011-04-21 22:00:33 -040012 public function test_br()
13 {
14 $this->assertEquals('<br /><br />', br(2));
15 }
Andrey Andreev99b782d2012-06-09 22:24:46 +030016
Eric Barnes68286a42011-04-21 22:00:33 -040017 // ------------------------------------------------------------------------
Andrey Andreev99b782d2012-06-09 22:24:46 +030018
Eric Barnes68286a42011-04-21 22:00:33 -040019 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 // ------------------------------------------------------------------------
Andrey Andreev99b782d2012-06-09 22:24:46 +030026
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);
Greg Akerb5679472011-04-21 14:34:31 -050038 $list = array('foo', 'bar');
Greg Akerb5679472011-04-21 14:34:31 -050039
Andrey Andreev99b782d2012-06-09 22:24:46 +030040 $this->assertEquals(ltrim($expect), ul($list));
Greg Akerb5679472011-04-21 14:34:31 -050041
42 $expect = <<<EOH
43<ul class="test">
44 <li>foo</li>
45 <li>bar</li>
46</ul>
47
48EOH;
49
50 $expect = ltrim($expect);
51
Greg Aker92ff07e2011-08-20 16:57:48 -050052 $this->assertEquals($expect, ul($list, 'class="test"'));
Greg Akerb5679472011-04-21 14:34:31 -050053
54 $this->assertEquals($expect, ul($list, array('class' => 'test')));
55 }
Andrey Andreev99b782d2012-06-09 22:24:46 +030056
Greg Akerb5679472011-04-21 14:34:31 -050057 // ------------------------------------------------------------------------
58
Eric Barnes68286a42011-04-21 22:00:33 -040059 public function test_NBS()
Greg Akerb5679472011-04-21 14:34:31 -050060 {
61 $this->assertEquals('&nbsp;&nbsp;&nbsp;', nbs(3));
62 }
63
64 // ------------------------------------------------------------------------
Andrey Andreev99b782d2012-06-09 22:24:46 +030065
Eric Barnes68286a42011-04-21 22:00:33 -040066 public function test_meta()
Greg Akerb5679472011-04-21 14:34:31 -050067 {
68 $this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo'));
Andrey Andreev99b782d2012-06-09 22:24:46 +030069
Greg Akerb5679472011-04-21 14:34:31 -050070 $expect = "<meta name=\"foo\" content=\"\" />\n";
Andrey Andreev99b782d2012-06-09 22:24:46 +030071
Greg Akerb5679472011-04-21 14:34:31 -050072 $this->assertEquals($expect, meta(array('name' => 'foo')));
Andrey Andreev99b782d2012-06-09 22:24:46 +030073
Greg Akerb5679472011-04-21 14:34:31 -050074 }
Andrey Andreev99b782d2012-06-09 22:24:46 +030075
Greg Akerb5679472011-04-21 14:34:31 -050076}