1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace Tests\Suilven\RandomEnglish\Helper; |
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
6
|
|
|
use Suilven\RandomEnglish\Helper\LanguageHelper; |
7
|
|
|
|
8
|
|
|
class LanguageHelperTest extends TestCase |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** @var \Suilven\RandomEnglish\Helper\LanguageHelper */ |
12
|
|
|
private $helper; |
13
|
|
|
|
14
|
|
|
public function setUp(): void |
15
|
|
|
{ |
16
|
|
|
parent::setUp(); |
17
|
|
|
|
18
|
|
|
$this->helper = new LanguageHelper(); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
public function testPluralNouns(): void |
23
|
|
|
{ |
24
|
|
|
$this->assertEquals('trees', $this->helper->pluralizeNoun('tree')); |
25
|
|
|
$this->assertEquals('dogs', $this->helper->pluralizeNoun('dog')); |
26
|
|
|
$this->assertEquals('buses', $this->helper->pluralizeNoun('buses')); |
27
|
|
|
$this->assertEquals('sheep', $this->helper->pluralizeNoun('sheep')); |
28
|
|
|
$this->assertEquals('matrices', $this->helper->pluralizeNoun('matrix')); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
public function testIngVerb(): void |
33
|
|
|
{ |
34
|
|
|
$this->assertEquals('testing', $this->helper->ingVerb('test')); |
35
|
|
|
$this->assertEquals('kicking', $this->helper->ingVerb('kick')); |
36
|
|
|
$this->assertEquals('amusing', $this->helper->ingVerb('amuse')); |
37
|
|
|
$this->assertEquals('sitting', $this->helper->ingVerb('sit')); |
38
|
|
|
$this->assertEquals('clubbing', $this->helper->ingVerb('club')); |
39
|
|
|
$this->assertEquals('kidding', $this->helper->ingVerb('kid')); |
40
|
|
|
$this->assertEquals('dogging', $this->helper->ingVerb('dog')); |
41
|
|
|
$this->assertEquals('sporting', $this->helper->ingVerb('sport')); |
42
|
|
|
$this->assertEquals('spreading', $this->helper->ingVerb('spread')); |
43
|
|
|
$this->assertEquals('sweating', $this->helper->ingVerb('sweat')); |
44
|
|
|
$this->assertEquals('thinning', $this->helper->ingVerb('thin')); |
45
|
|
|
$this->assertEquals('thirding', $this->helper->ingVerb('third')); |
46
|
|
|
$this->assertEquals('warming', $this->helper->ingVerb('warm')); |
47
|
|
|
$this->assertEquals('weighting', $this->helper->ingVerb('weight')); |
48
|
|
|
$this->assertEquals('winding', $this->helper->ingVerb('wind')); |
49
|
|
|
$this->assertEquals("wilding", $this->helper->ingVerb("wild")); |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
$this->assertEquals("adding", $this->helper->ingVerb("add")); |
53
|
|
|
$this->assertEquals("bleeding", $this->helper->ingVerb("bleed")); |
54
|
|
|
$this->assertEquals("bottoming", $this->helper->ingVerb("bottom")); |
55
|
|
|
$this->assertEquals("browning", $this->helper->ingVerb("brown")); |
56
|
|
|
$this->assertEquals("burning", $this->helper->ingVerb("burn")); |
57
|
|
|
$this->assertEquals("chickening", $this->helper->ingVerb("chicken")); |
58
|
|
|
$this->assertEquals("climbing", $this->helper->ingVerb("climb")); |
59
|
|
|
$this->assertEquals("combing", $this->helper->ingVerb("comb")); |
60
|
|
|
$this->assertEquals("controlling", $this->helper->ingVerb("control")); |
61
|
|
|
$this->assertEquals("counting", $this->helper->ingVerb("count")); |
62
|
|
|
$this->assertEquals("developing", $this->helper->ingVerb("develop")); |
63
|
|
|
$this->assertEquals("dying", $this->helper->ingVerb("die")); |
64
|
|
|
$this->assertEquals("downing", $this->helper->ingVerb("down")); |
65
|
|
|
$this->assertEquals("dreaming", $this->helper->ingVerb("dream")); |
66
|
|
|
$this->assertEquals("earning", $this->helper->ingVerb("earn")); |
67
|
|
|
$this->assertEquals("egging", $this->helper->ingVerb("egg")); |
68
|
|
|
$this->assertEquals("equalling", $this->helper->ingVerb("equal")); |
69
|
|
|
$this->assertEquals("evening", $this->helper->ingVerb("even")); |
70
|
|
|
$this->assertEquals("eventing", $this->helper->ingVerb("event")); |
71
|
|
|
$this->assertEquals("excepting", $this->helper->ingVerb("except")); |
72
|
|
|
$this->assertEquals("faulting", $this->helper->ingVerb("fault")); |
73
|
|
|
$this->assertEquals("feeding", $this->helper->ingVerb("feed")); |
74
|
|
|
$this->assertEquals("filming", $this->helper->ingVerb("film")); |
75
|
|
|
$this->assertEquals("footing", $this->helper->ingVerb("foot")); |
76
|
|
|
$this->assertEquals("freeing", $this->helper->ingVerb("free")); |
77
|
|
|
$this->assertEquals("fronting", $this->helper->ingVerb("front")); |
78
|
|
|
$this->assertEquals("grouping", $this->helper->ingVerb("group")); |
79
|
|
|
$this->assertEquals("happening", $this->helper->ingVerb("happen")); |
80
|
|
|
$this->assertEquals("helping", $this->helper->ingVerb("help")); |
81
|
|
|
$this->assertEquals("inventing", $this->helper->ingVerb("invent")); |
82
|
|
|
$this->assertEquals("jumping", $this->helper->ingVerb("jump")); |
83
|
|
|
$this->assertEquals("keeping", $this->helper->ingVerb("keep")); |
84
|
|
|
$this->assertEquals("kneeing", $this->helper->ingVerb("knee")); |
85
|
|
|
$this->assertEquals("lamping", $this->helper->ingVerb("lamp")); |
86
|
|
|
$this->assertEquals("learning", $this->helper->ingVerb("learn")); |
87
|
|
|
$this->assertEquals("lying", $this->helper->ingVerb("lie")); |
88
|
|
|
$this->assertEquals("listening", $this->helper->ingVerb("listen")); |
89
|
|
|
$this->assertEquals("marketing", $this->helper->ingVerb("market")); |
90
|
|
|
$this->assertEquals("meeting", $this->helper->ingVerb("meet")); |
91
|
|
|
$this->assertEquals("needing", $this->helper->ingVerb("need")); |
92
|
|
|
$this->assertEquals("opening", $this->helper->ingVerb("open")); |
93
|
|
|
$this->assertEquals("outing", $this->helper->ingVerb("out")); |
94
|
|
|
$this->assertEquals("parenting", $this->helper->ingVerb("parent")); |
95
|
|
|
$this->assertEquals("pencilling", $this->helper->ingVerb("pencil")); |
96
|
|
|
$this->assertEquals("perfecting", $this->helper->ingVerb("perfect")); |
97
|
|
|
$this->assertEquals("planting", $this->helper->ingVerb("plant")); |
98
|
|
|
$this->assertEquals("pocketing", $this->helper->ingVerb("pocket")); |
99
|
|
|
$this->assertEquals("pointing", $this->helper->ingVerb("point")); |
100
|
|
|
$this->assertEquals("presenting", $this->helper->ingVerb("present")); |
101
|
|
|
$this->assertEquals("preventing", $this->helper->ingVerb("prevent")); |
102
|
|
|
$this->assertEquals("queening", $this->helper->ingVerb("queen")); |
103
|
|
|
$this->assertEquals("renting", $this->helper->ingVerb("rent")); |
104
|
|
|
$this->assertEquals("resulting", $this->helper->ingVerb("result")); |
105
|
|
|
$this->assertEquals("returning", $this->helper->ingVerb("return")); |
106
|
|
|
$this->assertEquals("rooming", $this->helper->ingVerb("room")); |
107
|
|
|
$this->assertEquals("seeing", $this->helper->ingVerb("see")); |
108
|
|
|
$this->assertEquals("seeding", $this->helper->ingVerb("seed")); |
109
|
|
|
$this->assertEquals("sharping", $this->helper->ingVerb("sharp")); |
110
|
|
|
$this->assertEquals("sheeting", $this->helper->ingVerb("sheet")); |
111
|
|
|
$this->assertEquals("shooting", $this->helper->ingVerb("shoot")); |
112
|
|
|
$this->assertEquals("shouting", $this->helper->ingVerb("shout")); |
113
|
|
|
$this->assertEquals("signalling", $this->helper->ingVerb("signal")); |
114
|
|
|
$this->assertEquals("sleeping", $this->helper->ingVerb("sleep")); |
115
|
|
|
$this->assertEquals("souping", $this->helper->ingVerb("soup")); |
116
|
|
|
$this->assertEquals("stamping", $this->helper->ingVerb("stamp")); |
117
|
|
|
$this->assertEquals("steaming", $this->helper->ingVerb("steam")); |
118
|
|
|
$this->assertEquals("teaming", $this->helper->ingVerb("team")); |
119
|
|
|
$this->assertEquals("totalling", $this->helper->ingVerb("total")); |
120
|
|
|
$this->assertEquals("travelling", $this->helper->ingVerb("travel")); |
121
|
|
|
$this->assertEquals("turning", $this->helper->ingVerb("turn")); |
122
|
|
|
$this->assertEquals("wanting", $this->helper->ingVerb("want")); |
123
|
|
|
$this->assertEquals("worrying", $this->helper->ingVerb("worry")); |
124
|
|
|
|
125
|
|
|
|
126
|
|
|
$this->assertEquals('stinging', $this->helper->ingVerb('sting')); |
127
|
|
|
$this->assertEquals('collecting', $this->helper->ingVerb('collect')); |
128
|
|
|
|
129
|
|
|
// @todo aim visit wait |
130
|
|
|
|
131
|
|
|
// possibly problematic |
132
|
|
|
$this->assertEquals("training", $this->helper->ingVerb("train")); |
133
|
|
|
$this->assertEquals("explaining", $this->helper->ingVerb("explain")); |
134
|
|
|
$this->assertEquals("containing", $this->helper->ingVerb("contain")); |
135
|
|
|
$this->assertEquals("coining", $this->helper->ingVerb("coin")); |
136
|
|
|
$this->assertEquals("joining", $this->helper->ingVerb("join")); |
137
|
|
|
|
138
|
|
|
//Counter example |
139
|
|
|
$this->assertEquals("spinning", $this->helper->ingVerb("spin")); |
140
|
|
|
$this->assertEquals("binning", $this->helper->ingVerb("bin")); |
141
|
|
|
|
142
|
|
|
|
143
|
|
|
$this->assertEquals("stationing", $this->helper->ingVerb("station")); |
144
|
|
|
$this->assertEquals("poisoning", $this->helper->ingVerb("poison")); |
145
|
|
|
$this->assertEquals("positioning", $this->helper->ingVerb("position")); |
146
|
|
|
$this->assertEquals("mooning", $this->helper->ingVerb("moon")); |
147
|
|
|
$this->assertEquals("ironing", $this->helper->ingVerb("iron")); |
148
|
|
|
$this->assertEquals("conditioning", $this->helper->ingVerb("condition")); |
149
|
|
|
$this->assertEquals("mentioning", $this->helper->ingVerb("mention")); |
150
|
|
|
$this->assertEquals("questioning", $this->helper->ingVerb("question")); |
151
|
|
|
|
152
|
|
|
//Counter example |
153
|
|
|
$this->assertEquals("conning", $this->helper->ingVerb("con")); |
154
|
|
|
|
155
|
|
|
|
156
|
|
|
$this->assertEquals("soaping", $this->helper->ingVerb("soap")); |
157
|
|
|
|
158
|
|
|
// counter example |
159
|
|
|
$this->assertEquals('clapping', $this->helper->ingVerb('clap')); |
160
|
|
|
|
161
|
|
|
|
162
|
|
|
|
163
|
|
|
$this->assertEquals("swimming", $this->helper->ingVerb("swim")); |
164
|
|
|
$this->assertEquals("trimming", $this->helper->ingVerb("trim")); |
165
|
|
|
|
166
|
|
|
// Counter example |
167
|
|
|
$this->assertEquals("timing", $this->helper->ingVerb("tim")); |
168
|
|
|
|
169
|
|
|
$this->assertEquals("waiting", $this->helper->ingVerb("wait")); |
170
|
|
|
$this->assertEquals('queuing', $this->helper->ingVerb('queue')); |
171
|
|
|
$this->assertEquals("visiting", $this->helper->ingVerb("visit")); |
172
|
|
|
$this->assertEquals("pooling", $this->helper->ingVerb("pool")); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
|
176
|
|
|
public function testAllVerbs(): void |
177
|
|
|
{ |
178
|
|
|
$wordType = 'verb'; |
179
|
|
|
$wordsFile = \dirname(__FILE__) . '/../../words/english_' . $wordType . 's.txt'; |
180
|
|
|
$words = \explode(\PHP_EOL, \trim(\file_get_contents($wordsFile))); |
181
|
|
|
foreach ($words as $word) { |
182
|
|
|
\error_log($word . ' --> ' . $this->helper->ingVerb($word)); |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
|