blob: 9e9478711c6185a9742e64c2d9b07ae62b261ddd [file] [log] [blame]
Greg Aker052b01d2011-04-21 14:38:03 -05001<?php
2
Greg Akerb4d93db2011-04-21 14:42:33 -05003class Inflector_helper_test extends CI_TestCase {
Greg Aker052b01d2011-04-21 14:38:03 -05004
Taufan Adityae1dc9ea2012-03-28 16:49:49 +07005 public function set_up()
6 {
7 $this->helper('inflector');
8 }
Greg Aker052b01d2011-04-21 14:38:03 -05009
Eric Barnes68286a42011-04-21 22:00:33 -040010 public function test_singular()
Greg Aker052b01d2011-04-21 14:38:03 -050011 {
12 $strs = array(
13 'tellies' => 'telly',
14 'smellies' => 'smelly',
15 'abjectnesses' => 'abjectness',
Hamza Bhatti2a6a6162012-03-15 09:45:29 +040016 'smells' => 'smell',
17 'equipment' => 'equipment'
Greg Aker052b01d2011-04-21 14:38:03 -050018 );
19
20 foreach ($strs as $str => $expect)
21 {
22 $this->assertEquals($expect, singular($str));
23 }
24 }
25
26 // --------------------------------------------------------------------
27
Eric Barnes68286a42011-04-21 22:00:33 -040028 public function test_plural()
Greg Aker052b01d2011-04-21 14:38:03 -050029 {
30 $strs = array(
31 'telly' => 'tellies',
32 'smelly' => 'smellies',
Taufan Aditya8749bc72012-03-11 05:43:45 +070033 'abjectness' => 'abjectnesses', // ref : http://en.wiktionary.org/wiki/abjectnesses
Greg Aker052b01d2011-04-21 14:38:03 -050034 'smell' => 'smells',
Hamza Bhatti2a6a6162012-03-15 09:45:29 +040035 'witch' => 'witches',
36 'equipment' => 'equipment'
Greg Aker052b01d2011-04-21 14:38:03 -050037 );
38
39 foreach ($strs as $str => $expect)
40 {
41 $this->assertEquals($expect, plural($str));
42 }
43 }
44
45 // --------------------------------------------------------------------
46
Eric Barnes68286a42011-04-21 22:00:33 -040047 public function test_camelize()
Greg Aker052b01d2011-04-21 14:38:03 -050048 {
49 $strs = array(
50 'this is the string' => 'thisIsTheString',
51 'this is another one' => 'thisIsAnotherOne',
52 'i-am-playing-a-trick' => 'i-am-playing-a-trick',
53 'what_do_you_think-yo?' => 'whatDoYouThink-yo?',
54 );
55
56 foreach ($strs as $str => $expect)
57 {
58 $this->assertEquals($expect, camelize($str));
59 }
60 }
61
62 // --------------------------------------------------------------------
63
Eric Barnes68286a42011-04-21 22:00:33 -040064 public function test_underscore()
Greg Aker052b01d2011-04-21 14:38:03 -050065 {
66 $strs = array(
67 'this is the string' => 'this_is_the_string',
68 'this is another one' => 'this_is_another_one',
69 'i-am-playing-a-trick' => 'i-am-playing-a-trick',
70 'what_do_you_think-yo?' => 'what_do_you_think-yo?',
71 );
72
73 foreach ($strs as $str => $expect)
74 {
75 $this->assertEquals($expect, underscore($str));
76 }
77 }
78
79 // --------------------------------------------------------------------
80
Eric Barnes68286a42011-04-21 22:00:33 -040081 public function test_humanize()
Greg Aker052b01d2011-04-21 14:38:03 -050082 {
83 $strs = array(
84 'this_is_the_string' => 'This Is The String',
85 'this_is_another_one' => 'This Is Another One',
86 'i-am-playing-a-trick' => 'I-am-playing-a-trick',
87 'what_do_you_think-yo?' => 'What Do You Think-yo?',
88 );
89
90 foreach ($strs as $str => $expect)
91 {
92 $this->assertEquals($expect, humanize($str));
93 }
94 }
95}