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 | } |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 9 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 10 | // ------------------------------------------------------------------------ |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 11 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 12 | public function test_br() |
| 13 | { |
| 14 | $this->assertEquals('<br /><br />', br(2)); |
| 15 | } |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 16 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 17 | // ------------------------------------------------------------------------ |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 18 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 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 | // ------------------------------------------------------------------------ |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 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); |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 38 | $list = array('foo', 'bar'); |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 39 | |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 40 | $this->assertEquals(ltrim($expect), ul($list)); |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 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 | |
Greg Aker | 92ff07e | 2011-08-20 16:57:48 -0500 | [diff] [blame] | 52 | $this->assertEquals($expect, ul($list, 'class="test"')); |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 53 | |
| 54 | $this->assertEquals($expect, ul($list, array('class' => 'test'))); |
| 55 | } |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 56 | |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 57 | // ------------------------------------------------------------------------ |
| 58 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 59 | public function test_NBS() |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 60 | { |
| 61 | $this->assertEquals(' ', nbs(3)); |
| 62 | } |
| 63 | |
| 64 | // ------------------------------------------------------------------------ |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 65 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 66 | public function test_meta() |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 67 | { |
| 68 | $this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo')); |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 69 | |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 70 | $expect = "<meta name=\"foo\" content=\"\" />\n"; |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 71 | |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 72 | $this->assertEquals($expect, meta(array('name' => 'foo'))); |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 73 | |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 74 | } |
Andrey Andreev | 99b782d | 2012-06-09 22:24:46 +0300 | [diff] [blame] | 75 | |
Greg Aker | b567947 | 2011-04-21 14:34:31 -0500 | [diff] [blame] | 76 | } |