summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/libraries/Table_test.php
diff options
context:
space:
mode:
authorBrennan Thompson <brenjt@gmail.com>2014-02-14 20:03:57 +0100
committerBrennan Thompson <brenjt@gmail.com>2014-02-14 20:03:57 +0100
commit6949f95f6e21980f36095490bf38fc8a172dbc0f (patch)
treeb3141f390acd0051396cda6a3da51c1f98384cca /tests/codeigniter/libraries/Table_test.php
parent68a02a01a086bbb1b8128ea2744439de84873d11 (diff)
parent81f036753272391360ba5b64e6dd93c4101a8733 (diff)
Merge remote-tracking branch 'upstream/develop' into develop
Conflicts: system/helpers/form_helper.php
Diffstat (limited to 'tests/codeigniter/libraries/Table_test.php')
-rw-r--r--tests/codeigniter/libraries/Table_test.php51
1 files changed, 29 insertions, 22 deletions
diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php
index ce04b6a6d..8e7452474 100644
--- a/tests/codeigniter/libraries/Table_test.php
+++ b/tests/codeigniter/libraries/Table_test.php
@@ -34,7 +34,7 @@ class Table_test extends CI_TestCase {
}
/*
- * @depends testPrepArgs
+ * @depends test_prep_args
*/
public function test_set_heading()
{
@@ -55,7 +55,7 @@ class Table_test extends CI_TestCase {
}
/*
- * @depends testPrepArgs
+ * @depends test_prep_args
*/
public function test_add_row()
{
@@ -200,16 +200,14 @@ class Table_test extends CI_TestCase {
public function test_set_from_array()
{
- $this->assertFalse($this->table->set_from_array('bogus'));
- $this->assertFalse($this->table->set_from_array(NULL));
-
$data = array(
array('name', 'color', 'number'),
array('Laura', 'Red', '22'),
array('Katie', 'Blue')
);
- $this->table->set_from_array($data, FALSE);
+ $this->table->auto_heading = FALSE;
+ $this->table->set_from_array($data);
$this->assertEmpty($this->table->heading);
$this->table->clear();
@@ -235,22 +233,14 @@ class Table_test extends CI_TestCase {
public function test_set_from_object()
{
- // Make a stub of query instance
- $query = new CI_TestCase();
- $query->list_fields = function(){
- return array('name', 'email');
- };
- $query->result_array = function(){
- return array(
- array('name' => 'John Doe', 'email' => 'john@doe.com'),
- array('name' => 'Foo Bar', 'email' => 'foo@bar.com'),
- );
- };
- $query->num_rows = function(){
- return 2;
- };
-
- $this->table->set_from_object($query);
+ // This needs to be passed by reference to CI_DB_result::__construct()
+ $dummy = new stdClass();
+ $dummy->conn_id = NULL;
+ $dummy->result_id = NULL;
+
+ $db_result = new DB_result_dummy($dummy);
+
+ $this->table->set_from_db_result($db_result);
$expected = array(
array('data' => 'name'),
@@ -290,4 +280,21 @@ class Table_test extends CI_TestCase {
$this->assertTrue(strpos($table, '<td>Small</td>') !== FALSE);
}
+}
+
+// We need this for the _set_from_db_result() test
+class DB_result_dummy extends CI_DB_result
+{
+ public function list_fields()
+ {
+ return array('name', 'email');
+ }
+
+ public function result_array()
+ {
+ return array(
+ array('name' => 'John Doe', 'email' => 'john@doe.com'),
+ array('name' => 'Foo Bar', 'email' => 'foo@bar.com')
+ );
+ }
} \ No newline at end of file