11<?php
22
3- use PHPUnit \Framework \TestCase ;
43use DivineOmega \WordInfo \Word ;
4+ use PHPUnit \Framework \TestCase ;
55
66final class WordTest extends TestCase
77{
88 public function testRhymes ()
99 {
1010 $ rhymes = (new Word ('cat ' ))->rhymes ();
1111
12- $ expected = ['aristocrat ' , 'at ' , 'bat ' , 'caveat ' , 'chat ' , 'democrat ' , 'diplomat ' ,
13- 'fat ' , 'flat ' , 'habitat ' , 'hat ' , 'mat ' , 'pat ' , 'rat ' , 'sat ' , 'spat ' ,
14- 'stat ' , 'tat ' , 'that ' , 'thermostat ' , 'vat ' ];
12+ $ expected = ['aristocrat ' , 'at ' , 'bat ' , 'caveat ' , 'chat ' , 'democrat ' , 'diplomat ' ,
13+ 'fat ' , 'flat ' , 'habitat ' , 'hat ' , 'mat ' , 'pat ' , 'rat ' , 'sat ' , 'spat ' ,
14+ 'stat ' , 'tat ' , 'that ' , 'thermostat ' , 'vat ' , ];
1515
1616 $ this ->assertEquals ($ expected , $ rhymes );
1717 }
@@ -20,9 +20,9 @@ public function testHalfRhymes()
2020 {
2121 $ rhymes = (new Word ('violet ' ))->halfRhymes ();
2222
23- $ expected = ['cyclist ' , 'finalist ' , 'hybridised ' , 'iodised ' , 'ionised ' , 'lionised ' ,
24- 'motorcyclist ' , 'nihilist ' , 'piloted ' , 'pirated ' , 'playacted ' , 'revivalist ' ,
25- 'rioted ' , 'scientist ' , 'semifinalist ' , 'survivalist ' ];
23+ $ expected = ['cyclist ' , 'finalist ' , 'hybridised ' , 'iodised ' , 'ionised ' , 'lionised ' ,
24+ 'motorcyclist ' , 'nihilist ' , 'piloted ' , 'pirated ' , 'playacted ' , 'revivalist ' ,
25+ 'rioted ' , 'scientist ' , 'semifinalist ' , 'survivalist ' , ];
2626
2727 $ this ->assertEquals ($ expected , $ rhymes );
2828 }
@@ -95,20 +95,20 @@ public function testPortmanteaus1()
9595 {
9696 $ portmanteaus = (new Word ('computer ' ))->portmanteaus ();
9797
98- $ expected = ['computarena ' , 'computarise ' , 'computarisen ' , 'computarises ' , 'computarising ' , 'computaristocratic ' , 'computaroma ' ,
99- 'computarose ' , 'computaround ' , 'computarousal ' , 'computarouse ' , 'computaroused ' , 'computarousing ' , 'computarrange ' ,
98+ $ expected = ['computarena ' , 'computarise ' , 'computarisen ' , 'computarises ' , 'computarising ' , 'computaristocratic ' , 'computaroma ' ,
99+ 'computarose ' , 'computaround ' , 'computarousal ' , 'computarouse ' , 'computaroused ' , 'computarousing ' , 'computarrange ' ,
100100 'computarranged ' , 'computarrangement ' , 'computarrangements ' , 'computarranging ' , 'computarray ' , 'computarrears ' , 'computarrest ' ,
101- 'computarrested ' , 'computarresting ' , 'computarrests ' , 'computarrhythmias ' , 'computarrival ' , 'computarrivals ' , 'computarrive ' ,
102- 'computarrived ' , 'computarrives ' , 'computarriving ' , 'computerena ' , 'computeriginal ' , 'computeriginality ' , 'computeriginally ' ,
103- 'computeriginals ' , 'computeriginate ' , 'computeriginated ' , 'computeriginates ' , 'computeriginating ' , 'computerine ' , 'computerise ' ,
104- 'computerisen ' , 'computerises ' , 'computerising ' , 'computeristocratic ' , 'computermination ' , 'computeroma ' , 'computerose ' ,
105- 'computeround ' , 'computerousal ' , 'computerouse ' , 'computeroused ' , 'computerousing ' , 'computerrain ' , 'computerrestrial ' ,
106- 'computerrific ' , 'computerrrange ' , 'computerrranged ' , 'computerrrangement ' , 'computerrrangements ' , 'computerrranging ' ,
107- 'computerrray ' , 'computerrrears ' , 'computerrrest ' , 'computerrrested ' , 'computerrresting ' , 'computerrrests ' , 'computerrrhythmias ' ,
108- 'computerrrival ' , 'computerrrivals ' , 'computerrrive ' , 'computerrrived ' , 'computerrrives ' , 'computerrriving ' , 'computerus ' ,
109- 'computeryrannical ' , 'computoriginal ' , 'computoriginality ' , 'computoriginally ' , 'computoriginals ' , 'computoriginate ' ,
110- 'computoriginated ' , 'computoriginates ' , 'computoriginating ' , 'computyrannical ' , 'incomputer ' , 'outcomputer ' , 'silicaomputer ' ,
111- 'silicomputer ' , 'welcomputer ' ];
101+ 'computarrested ' , 'computarresting ' , 'computarrests ' , 'computarrhythmias ' , 'computarrival ' , 'computarrivals ' , 'computarrive ' ,
102+ 'computarrived ' , 'computarrives ' , 'computarriving ' , 'computerena ' , 'computeriginal ' , 'computeriginality ' , 'computeriginally ' ,
103+ 'computeriginals ' , 'computeriginate ' , 'computeriginated ' , 'computeriginates ' , 'computeriginating ' , 'computerine ' , 'computerise ' ,
104+ 'computerisen ' , 'computerises ' , 'computerising ' , 'computeristocratic ' , 'computermination ' , 'computeroma ' , 'computerose ' ,
105+ 'computeround ' , 'computerousal ' , 'computerouse ' , 'computeroused ' , 'computerousing ' , 'computerrain ' , 'computerrestrial ' ,
106+ 'computerrific ' , 'computerrrange ' , 'computerrranged ' , 'computerrrangement ' , 'computerrrangements ' , 'computerrranging ' ,
107+ 'computerrray ' , 'computerrrears ' , 'computerrrest ' , 'computerrrested ' , 'computerrresting ' , 'computerrrests ' , 'computerrrhythmias ' ,
108+ 'computerrrival ' , 'computerrrivals ' , 'computerrrive ' , 'computerrrived ' , 'computerrrives ' , 'computerrriving ' , 'computerus ' ,
109+ 'computeryrannical ' , 'computoriginal ' , 'computoriginality ' , 'computoriginally ' , 'computoriginals ' , 'computoriginate ' ,
110+ 'computoriginated ' , 'computoriginates ' , 'computoriginating ' , 'computyrannical ' , 'incomputer ' , 'outcomputer ' , 'silicaomputer ' ,
111+ 'silicomputer ' , 'welcomputer ' , ];
112112
113113 $ this ->assertEquals ($ expected , $ portmanteaus );
114114 }
@@ -117,10 +117,54 @@ public function testPortmanteaus2()
117117 {
118118 $ portmanteaus = (new Word ('cheese ' ))->portmanteaus ();
119119
120- $ expected = ['chease ' , 'cheased ' , 'cheasel ' , 'cheasement ' , 'cheasements ' , 'cheases ' , 'cheasier ' , 'cheasiest ' , 'cheasily ' , 'cheasing ' ,
121- 'cheasy ' , 'cheasygoing ' , 'chies ' , 'chiheese ' , 'chiis ' , 'chization ' , 'chys ' ];
120+ $ expected = ['chease ' , 'cheased ' , 'cheasel ' , 'cheasement ' , 'cheasements ' , 'cheases ' , 'cheasier ' , 'cheasiest ' , 'cheasily ' , 'cheasing ' ,
121+ 'cheasy ' , 'cheasygoing ' , 'chies ' , 'chiheese ' , 'chiis ' , 'chization ' , 'chys ' , ];
122122
123123 $ this ->assertEquals ($ expected , $ portmanteaus );
124124 }
125125
126- }
126+ private function getSingularToPluralData ()
127+ {
128+ return [
129+ 'cat ' => 'cats ' ,
130+ 'mitten ' => 'mittens ' ,
131+ 'sausage ' => 'sausages ' ,
132+ 'child ' => 'children ' ,
133+ 'goose ' => 'geese ' ,
134+ 'person ' => 'people ' ,
135+ 'woman ' => 'women ' ,
136+ 'man ' => 'men ' ,
137+ 'audio ' => 'audio ' ,
138+ 'education ' => 'education ' ,
139+ 'rice ' => 'rice ' ,
140+ 'love ' => 'love ' ,
141+ 'pokemon ' => 'pokemon ' ,
142+ 'sheep ' => 'sheep ' ,
143+ 'sex ' => 'sexes ' ,
144+ 'mouse ' => 'mice ' ,
145+ 'mathematics ' => 'mathematics ' ,
146+ 'information ' => 'information ' ,
147+ 'tooth ' => 'teeth ' ,
148+ ];
149+ }
150+
151+ public function testPluralise ()
152+ {
153+ $ data = $ this ->getSingularToPluralData ();
154+
155+ foreach ($ data as $ singular => $ plural ) {
156+ $ word = new Word ($ singular );
157+ $ this ->assertEquals ($ plural , $ word ->plural ());
158+ }
159+ }
160+
161+ public function testSingularise ()
162+ {
163+ $ data = $ this ->getSingularToPluralData ();
164+
165+ foreach ($ data as $ singular => $ plural ) {
166+ $ word = new Word ($ plural );
167+ $ this ->assertEquals ($ singular , $ word ->singular ());
168+ }
169+ }
170+ }
0 commit comments