Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | require_once(BASEPATH.'helpers/html_helper.php'); |
| 4 | |
Greg Aker | b4d93db | 2011-04-21 14:42:33 -0500 | [diff] [blame] | 5 | class Html_helper_test extends CI_TestCase |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 6 | { |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 7 | |
| 8 | // ------------------------------------------------------------------------ |
| 9 | |
| 10 | public function test_br() |
| 11 | { |
| 12 | $this->assertEquals('<br /><br />', br(2)); |
| 13 | } |
| 14 | |
| 15 | // ------------------------------------------------------------------------ |
| 16 | |
| 17 | public function test_heading() |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 18 | { |
| 19 | $this->assertEquals('<h1>foobar</h1>', heading('foobar')); |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 20 | $this->assertEquals('<h2 class="bar">foobar</h2>', heading('foobar', 2, 'class="bar"')); |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | // ------------------------------------------------------------------------ |
| 24 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 25 | public function test_Ul() |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 26 | { |
| 27 | $expect = <<<EOH |
| 28 | <ul> |
| 29 | <li>foo</li> |
| 30 | <li>bar</li> |
| 31 | </ul> |
| 32 | |
| 33 | EOH; |
| 34 | |
| 35 | $expect = ltrim($expect); |
| 36 | |
| 37 | $list = array('foo', 'bar'); |
| 38 | |
| 39 | $this->assertEquals($expect, ul($list)); |
| 40 | |
| 41 | |
| 42 | $expect = <<<EOH |
| 43 | <ul class="test"> |
| 44 | <li>foo</li> |
| 45 | <li>bar</li> |
| 46 | </ul> |
| 47 | |
| 48 | EOH; |
| 49 | |
| 50 | $expect = ltrim($expect); |
| 51 | |
| 52 | $list = array('foo', 'bar'); |
| 53 | |
Greg Aker | 92ff07e | 2011-08-20 16:57:48 -0500 | [diff] [blame^] | 54 | $this->assertEquals($expect, ul($list, 'class="test"')); |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 55 | |
| 56 | $this->assertEquals($expect, ul($list, array('class' => 'test'))); |
| 57 | } |
| 58 | |
| 59 | // ------------------------------------------------------------------------ |
| 60 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 61 | public function test_NBS() |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 62 | { |
| 63 | $this->assertEquals(' ', nbs(3)); |
| 64 | } |
| 65 | |
| 66 | // ------------------------------------------------------------------------ |
| 67 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 68 | public function test_meta() |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 69 | { |
| 70 | $this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo')); |
| 71 | |
| 72 | $expect = "<meta name=\"foo\" content=\"\" />\n"; |
| 73 | |
| 74 | $this->assertEquals($expect, meta(array('name' => 'foo'))); |
| 75 | |
| 76 | } |
| 77 | |
| 78 | } |