Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 1 | <?php |
| 2 | |
Taufan Aditya | ac5373a | 2012-03-28 16:03:38 +0700 | [diff] [blame] | 3 | class Table_test extends CI_TestCase { |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 4 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 5 | public function set_up() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 6 | { |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 7 | $this->table = new Mock_Libraries_Table(); |
| 8 | $this->ci_instance_var('table', $this->table); |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 9 | } |
| 10 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 11 | // Setter Methods |
| 12 | // -------------------------------------------------------------------- |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 13 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 14 | public function test_set_template() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 15 | { |
| 16 | $this->assertFalse($this->table->set_template('not an array')); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 17 | |
| 18 | $template = array('a' => 'b'); |
| 19 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 20 | $this->table->set_template($template); |
| 21 | $this->assertEquals($template, $this->table->template); |
| 22 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 23 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 24 | public function test_set_empty() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 25 | { |
| 26 | $this->table->set_empty('nada'); |
| 27 | $this->assertEquals('nada', $this->table->empty_cells); |
| 28 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 29 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 30 | public function test_set_caption() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 31 | { |
| 32 | $this->table->set_caption('awesome cap'); |
| 33 | $this->assertEquals('awesome cap', $this->table->caption); |
| 34 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 35 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 36 | /* |
Andrey Andreev | 1b4e5e1 | 2014-02-13 01:14:28 +0200 | [diff] [blame] | 37 | * @depends test_prep_args |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 38 | */ |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 39 | public function test_set_heading() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 40 | { |
| 41 | // uses _prep_args internally, so we'll just do a quick |
| 42 | // check to verify that func_get_args and prep_args are |
| 43 | // being called. |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 44 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 45 | $this->table->set_heading('name', 'color', 'size'); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 46 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 47 | $this->assertEquals( |
| 48 | array( |
| 49 | array('data' => 'name'), |
| 50 | array('data' => 'color'), |
| 51 | array('data' => 'size') |
| 52 | ), |
| 53 | $this->table->heading |
| 54 | ); |
| 55 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 56 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 57 | /* |
Andrey Andreev | 1b4e5e1 | 2014-02-13 01:14:28 +0200 | [diff] [blame] | 58 | * @depends test_prep_args |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 59 | */ |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 60 | public function test_add_row() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 61 | { |
| 62 | // uses _prep_args internally, so we'll just do a quick |
| 63 | // check to verify that func_get_args and prep_args are |
| 64 | // being called. |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 65 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 66 | $this->table->add_row('my', 'pony', 'sings'); |
| 67 | $this->table->add_row('your', 'pony', 'stinks'); |
| 68 | $this->table->add_row('my pony', '>', 'your pony'); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 69 | |
Andrey Andreev | 20d9b0a | 2017-12-20 19:57:39 +0200 | [diff] [blame^] | 70 | $this->assertCount(3, $this->table->rows); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 71 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 72 | $this->assertEquals( |
| 73 | array( |
| 74 | array('data' => 'your'), |
| 75 | array('data' => 'pony'), |
| 76 | array('data' => 'stinks') |
| 77 | ), |
| 78 | $this->table->rows[1] |
| 79 | ); |
| 80 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 81 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 82 | // Uility Methods |
| 83 | // -------------------------------------------------------------------- |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 84 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 85 | public function test_prep_args() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 86 | { |
| 87 | $expected = array( |
| 88 | array('data' => 'name'), |
| 89 | array('data' => 'color'), |
| 90 | array('data' => 'size') |
| 91 | ); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 92 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 93 | $this->assertEquals( |
| 94 | $expected, |
Taufan Aditya | 30b34d0 | 2012-03-28 16:35:48 +0700 | [diff] [blame] | 95 | $this->table->prep_args(array('name', 'color', 'size')) |
tiyowan | e39728c | 2012-03-10 02:10:44 +0400 | [diff] [blame] | 96 | ); |
Taufan Aditya | 30b34d0 | 2012-03-28 16:35:48 +0700 | [diff] [blame] | 97 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 98 | // with cell attributes |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 99 | // need to add that new argument row to our expected outcome |
| 100 | $expected[] = array('data' => 'weight', 'class' => 'awesome'); |
tiyowan | e39728c | 2012-03-10 02:10:44 +0400 | [diff] [blame] | 101 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 102 | $this->assertEquals( |
| 103 | $expected, |
Taufan Aditya | 30b34d0 | 2012-03-28 16:35:48 +0700 | [diff] [blame] | 104 | $this->table->prep_args(array('name', 'color', 'size', array('data' => 'weight', 'class' => 'awesome'))) |
tiyowan | e39728c | 2012-03-10 02:10:44 +0400 | [diff] [blame] | 105 | ); |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 106 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 107 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 108 | public function test_default_template_keys() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 109 | { |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 110 | $keys = array( |
| 111 | 'table_open', |
| 112 | 'thead_open', 'thead_close', |
| 113 | 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', |
| 114 | 'tbody_open', 'tbody_close', |
| 115 | 'row_start', 'row_end', 'cell_start', 'cell_end', |
| 116 | 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', |
| 117 | 'table_close' |
| 118 | ); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 119 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 120 | foreach ($keys as $key) |
| 121 | { |
Taufan Aditya | d61b772 | 2012-03-28 16:07:58 +0700 | [diff] [blame] | 122 | $this->assertArrayHasKey($key, $this->table->default_template()); |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 123 | } |
| 124 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 125 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 126 | public function test_compile_template() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 127 | { |
| 128 | $this->assertFalse($this->table->set_template('invalid_junk')); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 129 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 130 | // non default key |
| 131 | $this->table->set_template(array('nonsense' => 'foo')); |
Taufan Aditya | d44d720 | 2012-03-28 16:24:23 +0700 | [diff] [blame] | 132 | $this->table->compile_template(); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 133 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 134 | $this->assertArrayHasKey('nonsense', $this->table->template); |
| 135 | $this->assertEquals('foo', $this->table->template['nonsense']); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 136 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 137 | // override default |
| 138 | $this->table->set_template(array('table_close' => '</table junk>')); |
Taufan Aditya | d44d720 | 2012-03-28 16:24:23 +0700 | [diff] [blame] | 139 | $this->table->compile_template(); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 140 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 141 | $this->assertArrayHasKey('table_close', $this->table->template); |
| 142 | $this->assertEquals('</table junk>', $this->table->template['table_close']); |
| 143 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 144 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 145 | public function test_make_columns() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 146 | { |
| 147 | // Test bogus parameters |
| 148 | $this->assertFalse($this->table->make_columns('invalid_junk')); |
Taufan Aditya | 8749bc7 | 2012-03-11 05:43:45 +0700 | [diff] [blame] | 149 | $this->assertFalse($this->table->make_columns(array())); |
| 150 | $this->assertFalse($this->table->make_columns(array('one', 'two'), '2.5')); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 151 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 152 | // Now on to the actual column creation |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 153 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 154 | $five_values = array( |
| 155 | 'Laura', 'Red', '15', |
| 156 | 'Katie', 'Blue' |
| 157 | ); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 158 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 159 | // No column count - no changes to the array |
| 160 | $this->assertEquals( |
| 161 | $five_values, |
| 162 | $this->table->make_columns($five_values) |
| 163 | ); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 164 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 165 | // Column count of 3 leaves us with one |
| 166 | $this->assertEquals( |
| 167 | array( |
| 168 | array('Laura', 'Red', '15'), |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 169 | array('Katie', 'Blue', ' ') |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 170 | ), |
| 171 | $this->table->make_columns($five_values, 3) |
| 172 | ); |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 173 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 174 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 175 | public function test_clear() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 176 | { |
| 177 | $this->table->set_heading('Name', 'Color', 'Size'); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 178 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 179 | // Make columns changes auto_heading |
| 180 | $rows = $this->table->make_columns(array( |
| 181 | 'Laura', 'Red', '15', |
| 182 | 'Katie', 'Blue' |
| 183 | ), 3); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 184 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 185 | foreach ($rows as $row) |
| 186 | { |
| 187 | $this->table->add_row($row); |
| 188 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 189 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 190 | $this->assertFalse($this->table->auto_heading); |
Andrey Andreev | 20d9b0a | 2017-12-20 19:57:39 +0200 | [diff] [blame^] | 191 | $this->assertCount(3, $this->table->heading); |
| 192 | $this->assertCount(2, $this->table->rows); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 193 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 194 | $this->table->clear(); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 195 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 196 | $this->assertTrue($this->table->auto_heading); |
| 197 | $this->assertEmpty($this->table->heading); |
| 198 | $this->assertEmpty($this->table->rows); |
| 199 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 200 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 201 | public function test_set_from_array() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 202 | { |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 203 | $data = array( |
| 204 | array('name', 'color', 'number'), |
| 205 | array('Laura', 'Red', '22'), |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 206 | array('Katie', 'Blue') |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 207 | ); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 208 | |
Andrey Andreev | 05983fc | 2014-02-11 16:51:43 +0200 | [diff] [blame] | 209 | $this->table->auto_heading = FALSE; |
| 210 | $this->table->set_from_array($data); |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 211 | $this->assertEmpty($this->table->heading); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 212 | |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 213 | $this->table->clear(); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 214 | |
| 215 | $this->table->set_from_array($data); |
Andrey Andreev | 20d9b0a | 2017-12-20 19:57:39 +0200 | [diff] [blame^] | 216 | $this->assertCount(2, $this->table->rows); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 217 | |
| 218 | $expected = array( |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 219 | array('data' => 'name'), |
| 220 | array('data' => 'color'), |
| 221 | array('data' => 'number') |
| 222 | ); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 223 | |
| 224 | $this->assertEquals($expected, $this->table->heading); |
| 225 | |
| 226 | $expected = array( |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 227 | array('data' => 'Katie'), |
| 228 | array('data' => 'Blue'), |
| 229 | ); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 230 | |
| 231 | $this->assertEquals($expected, $this->table->rows[1]); |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 232 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 233 | |
| 234 | public function test_set_from_object() |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 235 | { |
Andrey Andreev | 05983fc | 2014-02-11 16:51:43 +0200 | [diff] [blame] | 236 | // This needs to be passed by reference to CI_DB_result::__construct() |
| 237 | $dummy = new stdClass(); |
| 238 | $dummy->conn_id = NULL; |
| 239 | $dummy->result_id = NULL; |
Taufan Aditya | 8749bc7 | 2012-03-11 05:43:45 +0700 | [diff] [blame] | 240 | |
Andrey Andreev | 05983fc | 2014-02-11 16:51:43 +0200 | [diff] [blame] | 241 | $db_result = new DB_result_dummy($dummy); |
| 242 | |
| 243 | $this->table->set_from_db_result($db_result); |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 244 | |
| 245 | $expected = array( |
Taufan Aditya | 8749bc7 | 2012-03-11 05:43:45 +0700 | [diff] [blame] | 246 | array('data' => 'name'), |
| 247 | array('data' => 'email') |
| 248 | ); |
| 249 | |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 250 | $this->assertEquals($expected, $this->table->heading); |
| 251 | |
| 252 | $expected = array( |
Taufan Aditya | 8749bc7 | 2012-03-11 05:43:45 +0700 | [diff] [blame] | 253 | 'name' => array('data' => 'Foo Bar'), |
| 254 | 'email' => array('data' => 'foo@bar.com'), |
| 255 | ); |
| 256 | |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 257 | $this->assertEquals($expected, $this->table->rows[1]); |
Greg Aker | 57fb518 | 2011-04-21 14:58:26 -0500 | [diff] [blame] | 258 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 259 | |
| 260 | public function test_generate() |
Taufan Aditya | 6c7526c | 2012-05-27 13:51:27 +0700 | [diff] [blame] | 261 | { |
| 262 | // Prepare the data |
| 263 | $data = array( |
| 264 | array('Name', 'Color', 'Size'), |
| 265 | array('Fred', 'Blue', 'Small'), |
| 266 | array('Mary', 'Red', 'Large'), |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 267 | array('John', 'Green', 'Medium') |
Taufan Aditya | 6c7526c | 2012-05-27 13:51:27 +0700 | [diff] [blame] | 268 | ); |
| 269 | |
| 270 | $table = $this->table->generate($data); |
| 271 | |
| 272 | // Test the table header |
Andrey Andreev | 20d9b0a | 2017-12-20 19:57:39 +0200 | [diff] [blame^] | 273 | $this->assertContains('<th>Name</th>', $table); |
| 274 | $this->assertContains('<th>Color</th>', $table); |
| 275 | $this->assertContains('<th>Size</th>', $table); |
Taufan Aditya | 6c7526c | 2012-05-27 13:51:27 +0700 | [diff] [blame] | 276 | |
| 277 | // Test the first entry |
Andrey Andreev | 20d9b0a | 2017-12-20 19:57:39 +0200 | [diff] [blame^] | 278 | $this->assertContains('<td>Fred</td>', $table); |
| 279 | $this->assertContains('<td>Blue</td>', $table); |
| 280 | $this->assertContains('<td>Small</td>', $table); |
Taufan Aditya | 6c7526c | 2012-05-27 13:51:27 +0700 | [diff] [blame] | 281 | } |
Andrey Andreev | c186288 | 2012-06-09 23:16:58 +0300 | [diff] [blame] | 282 | |
Andrey Andreev | 05983fc | 2014-02-11 16:51:43 +0200 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | // We need this for the _set_from_db_result() test |
| 286 | class DB_result_dummy extends CI_DB_result |
| 287 | { |
| 288 | public function list_fields() |
| 289 | { |
| 290 | return array('name', 'email'); |
| 291 | } |
| 292 | |
| 293 | public function result_array() |
| 294 | { |
| 295 | return array( |
| 296 | array('name' => 'John Doe', 'email' => 'john@doe.com'), |
| 297 | array('name' => 'Foo Bar', 'email' => 'foo@bar.com') |
| 298 | ); |
| 299 | } |
Andrey Andreev | 20d9b0a | 2017-12-20 19:57:39 +0200 | [diff] [blame^] | 300 | } |