summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-03-29 10:37:40 +0200
committerAndrey Andreev <narf@bofh.bg>2012-03-29 10:37:40 +0200
commitfd9e46e852d073ae6fb8680f26e9825805104e1c (patch)
treeab665546f404a61b2a97fa686ce1f7d2a37ffc79 /tests/codeigniter/libraries
parent16be2c2489535c79b38688413df26f95adbe0ea3 (diff)
parent38b2a256758ee8184d354cbdb0eac467118af36b (diff)
Merge upstream branch
Diffstat (limited to 'tests/codeigniter/libraries')
-rw-r--r--tests/codeigniter/libraries/Parser_test.php7
-rw-r--r--tests/codeigniter/libraries/Table_test.php74
-rw-r--r--tests/codeigniter/libraries/Typography_test.php7
-rw-r--r--tests/codeigniter/libraries/Useragent_test.php (renamed from tests/codeigniter/libraries/User_agent_test.php)10
4 files changed, 20 insertions, 78 deletions
diff --git a/tests/codeigniter/libraries/Parser_test.php b/tests/codeigniter/libraries/Parser_test.php
index b4580a4b1..c3d88fa85 100644
--- a/tests/codeigniter/libraries/Parser_test.php
+++ b/tests/codeigniter/libraries/Parser_test.php
@@ -1,14 +1,11 @@
<?php
-require BASEPATH.'libraries/Parser.php';
-
-class Parser_test extends CI_TestCase
-{
+class Parser_test extends CI_TestCase {
public function set_up()
{
$obj = new StdClass;
- $obj->parser = new CI_Parser();
+ $obj->parser = new Mock_Libraries_Parser();
$this->ci_instance($obj);
diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php
index 0208a465a..13f338c6b 100644
--- a/tests/codeigniter/libraries/Table_test.php
+++ b/tests/codeigniter/libraries/Table_test.php
@@ -1,14 +1,11 @@
<?php
-require BASEPATH.'libraries/Table.php';
-
-class Table_test extends CI_TestCase
-{
+class Table_test extends CI_TestCase {
public function set_up()
{
$obj = new StdClass;
- $obj->table = new CI_table();
+ $obj->table = new Mock_Libraries_Table();
$this->ci_instance($obj);
@@ -103,53 +100,23 @@ class Table_test extends CI_TestCase
array('data' => 'size')
);
- // test what would be discreet args,
- // basically means a single array as the calling method
- // will use func_get_args()
-
- $reflectionOfTable = new ReflectionClass($this->table);
- $method = $reflectionOfTable->getMethod('_prep_args');
-
- $method->setAccessible(true);
-
$this->assertEquals(
$expected,
- $method->invokeArgs(
- $this->table, array(array('name', 'color', 'size'), 'discreet')
- )
+ $this->table->prep_args(array('name', 'color', 'size'))
);
-
- // test what would be a single array argument. Again, nested
- // due to func_get_args on calling methods
- $this->assertEquals(
- $expected,
- $method->invokeArgs(
- $this->table, array(array('name', 'color', 'size'), 'array')
- )
- );
-
-
+
// with cell attributes
-
// need to add that new argument row to our expected outcome
$expected[] = array('data' => 'weight', 'class' => 'awesome');
$this->assertEquals(
$expected,
- $method->invokeArgs(
- $this->table, array(array('name', 'color', 'size', array('data' => 'weight', 'class' => 'awesome')), 'attributes')
- )
+ $this->table->prep_args(array('name', 'color', 'size', array('data' => 'weight', 'class' => 'awesome')))
);
}
public function test_default_template_keys()
{
- $reflectionOfTable = new ReflectionClass($this->table);
- $method = $reflectionOfTable->getMethod('_default_template');
-
- $method->setAccessible(true);
-
- $deft_template = $method->invoke($this->table);
$keys = array(
'table_open',
'thead_open', 'thead_close',
@@ -162,29 +129,24 @@ class Table_test extends CI_TestCase
foreach ($keys as $key)
{
- $this->assertArrayHasKey($key, $deft_template);
+ $this->assertArrayHasKey($key, $this->table->default_template());
}
}
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']);
@@ -250,13 +212,8 @@ class Table_test extends CI_TestCase
public function test_set_from_array()
{
- $reflectionOfTable = new ReflectionClass($this->table);
- $method = $reflectionOfTable->getMethod('_set_from_array');
-
- $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'),
@@ -264,7 +221,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();
@@ -280,7 +237,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(
@@ -296,11 +253,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(){
@@ -326,7 +278,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,
diff --git a/tests/codeigniter/libraries/Typography_test.php b/tests/codeigniter/libraries/Typography_test.php
index a0533bae0..250aefb24 100644
--- a/tests/codeigniter/libraries/Typography_test.php
+++ b/tests/codeigniter/libraries/Typography_test.php
@@ -1,14 +1,11 @@
<?php
-require BASEPATH.'libraries/Typography.php';
-
-class Typography_test extends CI_TestCase
-{
+class Typography_test extends CI_TestCase {
public function set_up()
{
$obj = new StdClass;
- $obj->type = new CI_Typography();
+ $obj->type = new Mock_Libraries_Typography();
$this->ci_instance($obj);
diff --git a/tests/codeigniter/libraries/User_agent_test.php b/tests/codeigniter/libraries/Useragent_test.php
index 6f9e87196..7dad7ac54 100644
--- a/tests/codeigniter/libraries/User_agent_test.php
+++ b/tests/codeigniter/libraries/Useragent_test.php
@@ -1,11 +1,7 @@
<?php
-require BASEPATH.'libraries/User_agent.php';
-
-// This class needs some work...
-
-class UserAgent_test extends CI_TestCase
-{
+class UserAgent_test extends CI_TestCase {
+
protected $_user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27';
protected $_mobile_ua = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7';
@@ -15,7 +11,7 @@ class UserAgent_test extends CI_TestCase
$_SERVER['HTTP_USER_AGENT'] = $this->_user_agent;
$obj = new StdClass;
- $obj->agent = new CI_User_agent();
+ $obj->agent = new Mock_Libraries_UserAgent();
$this->ci_instance($obj);