Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 1 | <?php |
| 2 | |
Taufan Aditya | e1dc9ea | 2012-03-28 16:49:49 +0700 | [diff] [blame] | 3 | class Html_helper_test extends CI_TestCase { |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 4 | |
Taufan Aditya | e1dc9ea | 2012-03-28 16:49:49 +0700 | [diff] [blame] | 5 | public function set_up() |
| 6 | { |
| 7 | $this->helper('html'); |
| 8 | } |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 9 | |
| 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 Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 20 | { |
| 21 | $this->assertEquals('<h1>foobar</h1>', heading('foobar')); |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 22 | $this->assertEquals('<h2 class="bar">foobar</h2>', heading('foobar', 2, 'class="bar"')); |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | // ------------------------------------------------------------------------ |
| 26 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 27 | public function test_Ul() |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 28 | { |
| 29 | $expect = <<<EOH |
| 30 | <ul> |
| 31 | <li>foo</li> |
| 32 | <li>bar</li> |
| 33 | </ul> |
| 34 | |
| 35 | EOH; |
| 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 | |
| 50 | EOH; |
| 51 | |
| 52 | $expect = ltrim($expect); |
| 53 | |
| 54 | $list = array('foo', 'bar'); |
| 55 | |
Greg Aker | 92ff07e | 2011-08-20 16:57:48 -0500 | [diff] [blame] | 56 | $this->assertEquals($expect, ul($list, 'class="test"')); |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 57 | |
| 58 | $this->assertEquals($expect, ul($list, array('class' => 'test'))); |
| 59 | } |
| 60 | |
| 61 | // ------------------------------------------------------------------------ |
| 62 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 63 | public function test_NBS() |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 64 | { |
| 65 | $this->assertEquals(' ', nbs(3)); |
| 66 | } |
| 67 | |
| 68 | // ------------------------------------------------------------------------ |
| 69 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 70 | public function test_meta() |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 71 | { |
| 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 | } |