diff options
author | Taufan Aditya <toopay@taufanaditya.com> | 2012-03-28 11:24:23 +0200 |
---|---|---|
committer | Taufan Aditya <toopay@taufanaditya.com> | 2012-03-28 11:24:23 +0200 |
commit | d44d720ba8b17fa58cb041111dca9c440f823446 (patch) | |
tree | fd5fe1a688748c3b0a21c31ecfaecf1072c19a4e /tests/codeigniter/libraries/Table_test.php | |
parent | d61b772e8c074644262218dff0b1f91a2f3b3a14 (diff) |
Implementation of Mock class, remove ugly reflection class
Diffstat (limited to 'tests/codeigniter/libraries/Table_test.php')
-rw-r--r-- | tests/codeigniter/libraries/Table_test.php | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php index 61678afc7..04396d5fe 100644 --- a/tests/codeigniter/libraries/Table_test.php +++ b/tests/codeigniter/libraries/Table_test.php @@ -159,23 +159,18 @@ class Table_test extends CI_TestCase { public function test_compile_template() { - $reflectionOfTable = new ReflectionClass($this->table); - $method = $reflectionOfTable->getMethod('_compile_template'); - - $method->setAccessible(true); - $this->assertFalse($this->table->set_template('invalid_junk')); // non default key $this->table->set_template(array('nonsense' => 'foo')); - $method->invoke($this->table); + $this->table->compile_template(); $this->assertArrayHasKey('nonsense', $this->table->template); $this->assertEquals('foo', $this->table->template['nonsense']); // override default $this->table->set_template(array('table_close' => '</table junk>')); - $method->invoke($this->table); + $this->table->compile_template(); $this->assertArrayHasKey('table_close', $this->table->template); $this->assertEquals('</table junk>', $this->table->template['table_close']); @@ -246,8 +241,8 @@ class Table_test extends CI_TestCase { $method->setAccessible(true); - $this->assertFalse($method->invokeArgs($this->table, array('bogus'))); - $this->assertFalse($method->invoke($this->table, array())); + $this->assertFalse($this->table->set_from_array('bogus')); + $this->assertFalse($this->table->set_from_array(NULL)); $data = array( array('name', 'color', 'number'), @@ -255,7 +250,7 @@ class Table_test extends CI_TestCase { array('Katie', 'Blue') ); - $method->invokeArgs($this->table, array($data, FALSE)); + $this->table->set_from_array($data, FALSE); $this->assertEmpty($this->table->heading); $this->table->clear(); @@ -271,7 +266,7 @@ class Table_test extends CI_TestCase { array('data' => 'Blue'), ); - $method->invokeArgs($this->table, array($data)); + $this->table->set_from_array($data); $this->assertEquals(count($this->table->rows), 2); $this->assertEquals( @@ -287,11 +282,6 @@ class Table_test extends CI_TestCase { function test_set_from_object() { - $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(){ @@ -317,7 +307,7 @@ class Table_test extends CI_TestCase { 'email' => array('data' => 'foo@bar.com'), ); - $method->invokeArgs($this->table, array($query)); + $this->table->set_from_object($query); $this->assertEquals( $expected_heading, |