From 052b01d9398de56e23300242f25d5317afcacf82 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 21 Apr 2011 14:38:03 -0500 Subject: Adding string helper and inflector helper tests --- .../codeigniter/helpers/inflector_helper_test.php | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 tests/codeigniter/helpers/inflector_helper_test.php (limited to 'tests/codeigniter/helpers/inflector_helper_test.php') diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php new file mode 100644 index 000000000..5e2fae9fd --- /dev/null +++ b/tests/codeigniter/helpers/inflector_helper_test.php @@ -0,0 +1,91 @@ + 'telly', + 'smellies' => 'smelly', + 'abjectnesses' => 'abjectness', + 'smells' => 'smell' + ); + + foreach ($strs as $str => $expect) + { + $this->assertEquals($expect, singular($str)); + } + } + + // -------------------------------------------------------------------- + + public function testPlural() + { + $strs = array( + 'telly' => 'tellies', + 'smelly' => 'smellies', + 'abjectness' => 'abjectness', + 'smell' => 'smells', + 'witch' => 'witches' + ); + + foreach ($strs as $str => $expect) + { + $this->assertEquals($expect, plural($str)); + } + } + + // -------------------------------------------------------------------- + + public function testCamelize() + { + $strs = array( + 'this is the string' => 'thisIsTheString', + 'this is another one' => 'thisIsAnotherOne', + 'i-am-playing-a-trick' => 'i-am-playing-a-trick', + 'what_do_you_think-yo?' => 'whatDoYouThink-yo?', + ); + + foreach ($strs as $str => $expect) + { + $this->assertEquals($expect, camelize($str)); + } + } + + // -------------------------------------------------------------------- + + public function testUnderscore() + { + $strs = array( + 'this is the string' => 'this_is_the_string', + 'this is another one' => 'this_is_another_one', + 'i-am-playing-a-trick' => 'i-am-playing-a-trick', + 'what_do_you_think-yo?' => 'what_do_you_think-yo?', + ); + + foreach ($strs as $str => $expect) + { + $this->assertEquals($expect, underscore($str)); + } + } + + // -------------------------------------------------------------------- + + public function testHumanize() + { + $strs = array( + 'this_is_the_string' => 'This Is The String', + 'this_is_another_one' => 'This Is Another One', + 'i-am-playing-a-trick' => 'I-am-playing-a-trick', + 'what_do_you_think-yo?' => 'What Do You Think-yo?', + ); + + foreach ($strs as $str => $expect) + { + $this->assertEquals($expect, humanize($str)); + } + } +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b4d93dbab7253f98613ab10e75e0ed20f06eaf19 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 21 Apr 2011 14:42:33 -0500 Subject: Updating helper test classes to extend CI_TestCase --- tests/codeigniter/helpers/inflector_helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter/helpers/inflector_helper_test.php') diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php index 5e2fae9fd..e59875e4a 100644 --- a/tests/codeigniter/helpers/inflector_helper_test.php +++ b/tests/codeigniter/helpers/inflector_helper_test.php @@ -2,7 +2,7 @@ require_once(BASEPATH.'helpers/inflector_helper.php'); -class Inflector_helper_test extends PHPUnit_Framework_TestCase { +class Inflector_helper_test extends CI_TestCase { public function testSingular() -- cgit v1.2.3-24-g4f1b