From 68286a4dcc1ed4d904ad992173c1b3621bf6fced Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Thu, 21 Apr 2011 22:00:33 -0400 Subject: Reworked unit tests to match rest of framework and added a few more. --- tests/codeigniter/helpers/number_helper_test.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/codeigniter/helpers/number_helper_test.php (limited to 'tests/codeigniter/helpers/number_helper_test.php') diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php new file mode 100644 index 000000000..02fc49c3d --- /dev/null +++ b/tests/codeigniter/helpers/number_helper_test.php @@ -0,0 +1,13 @@ +assertEquals('456 Bytes', byte_format(456)); + } + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 19379ef47a6bc0a788c65038bb59eca0b6624848 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Tue, 3 May 2011 22:16:11 -0400 Subject: Added unit tests for number helper. --- tests/codeigniter/helpers/number_helper_test.php | 71 +++++++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) (limited to 'tests/codeigniter/helpers/number_helper_test.php') diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php index 02fc49c3d..3322b2475 100644 --- a/tests/codeigniter/helpers/number_helper_test.php +++ b/tests/codeigniter/helpers/number_helper_test.php @@ -1,13 +1,78 @@ ci_core_class('lang'); + + // Mock away load, too much going on in there, + // we'll just check for the expected parameter + + $lang = $this->getMock($lang_cls, array('load')); + $lang->expects($this->once()) + ->method('load') + ->with($this->equalTo('number')); + + // Assign the proper language array + + $lang->language = $this->_get_lang('number'); + + // We don't have a controller, so just create + // a cheap class to act as our super object. + // Make sure it has a lang attribute. + + $obj = new StdClass; + $obj->lang = $lang; + $this->ci_instance($obj); + } + + // Quick helper to actually grab the language + // file. Consider moving this to ci_testcase? + public function _get_lang($name) + { + require BASEPATH.'language/english/'.$name.'_lang.php'; + return $lang; + } + public function test_byte_format() { - // $this->assertEquals('456 Bytes', byte_format(456)); + $this->assertEquals('456 Bytes', byte_format(456)); + } + + public function test_kb_format() + { + $this->assertEquals('4.5 KB', byte_format(4567)); + } + + public function test_kb_format_medium() + { + $this->assertEquals('44.6 KB', byte_format(45678)); } -} \ No newline at end of file + public function test_kb_format_large() + { + $this->assertEquals('446.1 KB', byte_format(456789)); + } + + public function test_mb_format() + { + $this->assertEquals('3.3 MB', byte_format(3456789)); + } + + public function test_gb_format() + { + $this->assertEquals('1.8 GB', byte_format(1932735283.2)); + } + + public function test_tb_format() + { + $this->assertEquals('112,283.3 TB', byte_format(123456789123456789)); + } +} + +// EOF \ No newline at end of file -- cgit v1.2.3-24-g4f1b From e1dc9ea4fcfd4983fa076b70fe631166a95d0b68 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Wed, 28 Mar 2012 16:49:49 +0700 Subject: Remove include or require declaration from all helpers test --- tests/codeigniter/helpers/number_helper_test.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tests/codeigniter/helpers/number_helper_test.php') diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php index 3322b2475..4bb9a918a 100644 --- a/tests/codeigniter/helpers/number_helper_test.php +++ b/tests/codeigniter/helpers/number_helper_test.php @@ -1,12 +1,11 @@ helper('number'); + // Grab the core lang class $lang_cls = $this->ci_core_class('lang'); -- cgit v1.2.3-24-g4f1b