blob: e59875e4ac38b65013a68e1cc3933cbc35a81237 [file] [log] [blame]
Greg Aker052b01d2011-04-21 14:38:03 -05001<?php
2
3require_once(BASEPATH.'helpers/inflector_helper.php');
4
Greg Akerb4d93db2011-04-21 14:42:33 -05005class Inflector_helper_test extends CI_TestCase {
Greg Aker052b01d2011-04-21 14:38:03 -05006
7
8 public function testSingular()
9 {
10 $strs = array(
11 'tellies' => 'telly',
12 'smellies' => 'smelly',
13 'abjectnesses' => 'abjectness',
14 'smells' => 'smell'
15 );
16
17 foreach ($strs as $str => $expect)
18 {
19 $this->assertEquals($expect, singular($str));
20 }
21 }
22
23 // --------------------------------------------------------------------
24
25 public function testPlural()
26 {
27 $strs = array(
28 'telly' => 'tellies',
29 'smelly' => 'smellies',
30 'abjectness' => 'abjectness',
31 'smell' => 'smells',
32 'witch' => 'witches'
33 );
34
35 foreach ($strs as $str => $expect)
36 {
37 $this->assertEquals($expect, plural($str));
38 }
39 }
40
41 // --------------------------------------------------------------------
42
43 public function testCamelize()
44 {
45 $strs = array(
46 'this is the string' => 'thisIsTheString',
47 'this is another one' => 'thisIsAnotherOne',
48 'i-am-playing-a-trick' => 'i-am-playing-a-trick',
49 'what_do_you_think-yo?' => 'whatDoYouThink-yo?',
50 );
51
52 foreach ($strs as $str => $expect)
53 {
54 $this->assertEquals($expect, camelize($str));
55 }
56 }
57
58 // --------------------------------------------------------------------
59
60 public function testUnderscore()
61 {
62 $strs = array(
63 'this is the string' => 'this_is_the_string',
64 'this is another one' => 'this_is_another_one',
65 'i-am-playing-a-trick' => 'i-am-playing-a-trick',
66 'what_do_you_think-yo?' => 'what_do_you_think-yo?',
67 );
68
69 foreach ($strs as $str => $expect)
70 {
71 $this->assertEquals($expect, underscore($str));
72 }
73 }
74
75 // --------------------------------------------------------------------
76
77 public function testHumanize()
78 {
79 $strs = array(
80 'this_is_the_string' => 'This Is The String',
81 'this_is_another_one' => 'This Is Another One',
82 'i-am-playing-a-trick' => 'I-am-playing-a-trick',
83 'what_do_you_think-yo?' => 'What Do You Think-yo?',
84 );
85
86 foreach ($strs as $str => $expect)
87 {
88 $this->assertEquals($expect, humanize($str));
89 }
90 }
91}