summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/helpers
diff options
context:
space:
mode:
authorTaufan Aditya <toopay@taufanaditya.com>2012-03-10 23:43:45 +0100
committerTaufan Aditya <toopay@taufanaditya.com>2012-03-10 23:43:45 +0100
commit8749bc7e836c196dfef37d3b7b5a67736a15092c (patch)
treeeb647bc246487f444ea1ffd4e24317ab0200bf30 /tests/codeigniter/helpers
parente40c763bf969acbaa7c4c61be50f01e870062080 (diff)
Fix incomplete and skipped test
Diffstat (limited to 'tests/codeigniter/helpers')
-rw-r--r--tests/codeigniter/helpers/date_helper_test.php56
-rw-r--r--tests/codeigniter/helpers/inflector_helper_test.php6
2 files changed, 50 insertions, 12 deletions
diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php
index c7a2c9b6e..662d16485 100644
--- a/tests/codeigniter/helpers/date_helper_test.php
+++ b/tests/codeigniter/helpers/date_helper_test.php
@@ -5,9 +5,39 @@ class Date_helper_test extends CI_TestCase
{
// ------------------------------------------------------------------------
- public function test_now()
+ public function test_now_local()
{
- $this->markTestIncomplete('not implemented yet');
+ // This stub job, is simply to cater $config['time_reference']
+ $config = $this->getMock('CI_Config');
+ $config->expects($this->any())
+ ->method('item')
+ ->will($this->returnValue('local'));
+
+ // Add the stub to our test instance
+ $this->ci_instance_var('config', $config);
+
+ $expected = time();
+ $test = now();
+ $this->assertEquals($expected, $test);
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_now_gmt()
+ {
+ // This stub job, is simply to cater $config['time_reference']
+ $config = $this->getMock('CI_Config');
+ $config->expects($this->any())
+ ->method('item')
+ ->will($this->returnValue('gmt'));
+
+ // Add the stub to our stdClass
+ $this->ci_instance_var('config', $config);
+
+ $t = time();
+ $expected = mktime(gmdate("H", $t), gmdate("i", $t), gmdate("s", $t), gmdate("m", $t), gmdate("d", $t), gmdate("Y", $t));
+ $test = now();
+ $this->assertEquals($expected, $test);
}
// ------------------------------------------------------------------------
@@ -124,7 +154,16 @@ class Date_helper_test extends CI_TestCase
public function test_timespan()
{
- $this->markTestIncomplete('not implemented yet');
+ $loader_cls = $this->ci_core_class('load');
+ $this->ci_instance_var('load', new $loader_cls);
+
+ $lang_cls = $this->ci_core_class('lang');
+ $this->ci_instance_var('lang', new $lang_cls);
+
+ $this->assertEquals('1 Second', timespan(time(), time()+1));
+ $this->assertEquals('1 Minute', timespan(time(), time()+60));
+ $this->assertEquals('1 Hour', timespan(time(), time()+3600));
+ $this->assertEquals('2 Hours', timespan(time(), time()+7200));
}
// ------------------------------------------------------------------------
@@ -140,7 +179,9 @@ class Date_helper_test extends CI_TestCase
public function test_local_to_gmt()
{
- $this->markTestIncomplete('not implemented yet');
+ $t = time();
+ $expected = mktime(gmdate("H", $t), gmdate("i", $t), gmdate("s", $t), gmdate("m", $t), gmdate("d", $t), gmdate("Y", $t));
+ $this->assertEquals($expected, local_to_gmt($t));
}
// ------------------------------------------------------------------------
@@ -177,9 +218,10 @@ class Date_helper_test extends CI_TestCase
public function test_human_to_unix()
{
- $time = time();
- $this->markTestIncomplete('Failed Test');
- // $this->assertEquals($time, human_to_unix(unix_to_human($time)));
+ $date = '2000-12-31 10:00:00 PM';
+ $expected = strtotime($date);
+ $this->assertEquals($expected, human_to_unix($date));
+ $this->assertFalse(human_to_unix());
}
// ------------------------------------------------------------------------
diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php
index ef1f54afc..e476f6dc8 100644
--- a/tests/codeigniter/helpers/inflector_helper_test.php
+++ b/tests/codeigniter/helpers/inflector_helper_test.php
@@ -24,14 +24,10 @@ class Inflector_helper_test extends CI_TestCase {
public function test_plural()
{
- $this->markTestSkipped(
- 'abjectness is breaking. SKipping for the time being.'
- );
-
$strs = array(
'telly' => 'tellies',
'smelly' => 'smellies',
- 'abjectness' => 'abjectness',
+ 'abjectness' => 'abjectnesses', // ref : http://en.wiktionary.org/wiki/abjectnesses
'smell' => 'smells',
'witch' => 'witches'
);