summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/libraries/Table_test.php
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2012-03-11 03:01:30 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2012-03-11 03:01:30 +0100
commit6efbe5d7312698c73bbd645950ff5c81793b21e7 (patch)
treeeb647bc246487f444ea1ffd4e24317ab0200bf30 /tests/codeigniter/libraries/Table_test.php
parente40c763bf969acbaa7c4c61be50f01e870062080 (diff)
parent8749bc7e836c196dfef37d3b7b5a67736a15092c (diff)
Merge pull request #1161 from toopay/unit-tests
Unit Tests marked as "Incomplete" now completed.
Diffstat (limited to 'tests/codeigniter/libraries/Table_test.php')
-rw-r--r--tests/codeigniter/libraries/Table_test.php51
1 files changed, 43 insertions, 8 deletions
diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php
index 045216b16..0208a465a 100644
--- a/tests/codeigniter/libraries/Table_test.php
+++ b/tests/codeigniter/libraries/Table_test.php
@@ -194,11 +194,8 @@ class Table_test extends CI_TestCase
{
// Test bogus parameters
$this->assertFalse($this->table->make_columns('invalid_junk'));
- $this->assertFalse( $this->table->make_columns(array()));
- // $this->assertFalse(
- // $this->table->make_columns(array('one', 'two')),
- // '2.5' // not an integer!
- // );
+ $this->assertFalse($this->table->make_columns(array()));
+ $this->assertFalse($this->table->make_columns(array('one', 'two'), '2.5'));
// Now on to the actual column creation
@@ -222,8 +219,6 @@ class Table_test extends CI_TestCase
),
$this->table->make_columns($five_values, 3)
);
-
- $this->markTestSkipped('Look at commented assertFalse above');
}
public function test_clear()
@@ -301,7 +296,47 @@ class Table_test extends CI_TestCase
function test_set_from_object()
{
- $this->markTestSkipped('Not yet implemented.');
+ $reflectionOfTable = new ReflectionClass($this->table);
+ $method = $reflectionOfTable->getMethod('_set_from_object');
+
+ $method->setAccessible(true);
+
+ // 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;
+ };
+
+ $expected_heading = array(
+ array('data' => 'name'),
+ array('data' => 'email')
+ );
+
+ $expected_second = array(
+ 'name' => array('data' => 'Foo Bar'),
+ 'email' => array('data' => 'foo@bar.com'),
+ );
+
+ $method->invokeArgs($this->table, array($query));
+
+ $this->assertEquals(
+ $expected_heading,
+ $this->table->heading
+ );
+
+ $this->assertEquals(
+ $expected_second,
+ $this->table->rows[1]
+ );
}
// Test main generate method