15
15
use Squirrel \Strings \Filter \RemoveExcessSpacesFilter ;
16
16
use Squirrel \Strings \Filter \RemoveHTMLTagCharacters ;
17
17
use Squirrel \Strings \Filter \RemoveHTMLTagsFilter ;
18
+ use Squirrel \Strings \Filter \RemoveNonAlphabeticFilter ;
18
19
use Squirrel \Strings \Filter \RemoveNonAlphanumericFilter ;
19
20
use Squirrel \Strings \Filter \RemoveNonAsciiAndControlCharactersFilter ;
20
21
use Squirrel \Strings \Filter \RemoveNonNumericFilter ;
@@ -57,78 +58,78 @@ class StringFilterTest extends \PHPUnit\Framework\TestCase
57
58
*
58
59
* @var string
59
60
*/
60
- private $ testString = " & haha <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " ;
61
+ private $ testString = " & haha 13 <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " ;
61
62
62
63
public function testDecodeAllHTMLEntities (): void
63
64
{
64
- $ this ->assertEquals (" & haha <strong>many</strong> \xc2\xa0 \xc2\xa0 grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new DecodeAllHTMLEntitiesFilter ())->filter ($ this ->testString ));
65
+ $ this ->assertEquals (" & haha 13 <strong>many</strong> \xc2\xa0 \xc2\xa0 grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new DecodeAllHTMLEntitiesFilter ())->filter ($ this ->testString ));
65
66
}
66
67
67
68
public function testDecodeBasicHTMLEntities (): void
68
69
{
69
- $ this ->assertEquals (" & haha <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new DecodeBasicHTMLEntitiesFilter ())->filter ($ this ->testString ));
70
+ $ this ->assertEquals (" & haha 13 <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new DecodeBasicHTMLEntitiesFilter ())->filter ($ this ->testString ));
70
71
}
71
72
72
73
public function testRemoveExcessSpaces (): void
73
74
{
74
- $ this ->assertEquals ("& haha <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\n\t\n\n<invalid> \"l'etat \"\\ thing contained!!!™ " , (new RemoveExcessSpacesFilter ())->filter ($ this ->testString ));
75
+ $ this ->assertEquals ("& haha 13 <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\n\t\n\n<invalid> \"l'etat \"\\ thing contained!!!™ " , (new RemoveExcessSpacesFilter ())->filter ($ this ->testString ));
75
76
}
76
77
77
78
public function testRemoveHTML (): void
78
79
{
79
- $ this ->assertEquals (" & haha many \xc2\xa0 grüss götter \r\n\n\n\t \n \n \"l'etat \"\\ thing contained!!!™ " , (new RemoveHTMLTagsFilter ())->filter ($ this ->testString ));
80
+ $ this ->assertEquals (" & haha 13many \xc2\xa0 grüss götter \r\n\n\n\t \n \n \"l'etat \"\\ thing contained!!!™ " , (new RemoveHTMLTagsFilter ())->filter ($ this ->testString ));
80
81
}
81
82
82
83
public function testReplaceNewlinesWithSpaces (): void
83
84
{
84
- $ this ->assertEquals (" & haha <strong>many</strong> \xc2\xa0 grüss götter \t <invalid> \"l'etat \"\\ thing contained!!!™ " , (new ReplaceNewlinesWithSpacesFilter ())->filter ($ this ->testString ));
85
+ $ this ->assertEquals (" & haha 13 <strong>many</strong> \xc2\xa0 grüss götter \t <invalid> \"l'etat \"\\ thing contained!!!™ " , (new ReplaceNewlinesWithSpacesFilter ())->filter ($ this ->testString ));
85
86
}
86
87
87
88
public function testReplaceTabsWithSpaces (): void
88
89
{
89
- $ this ->assertEquals (" & haha <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\n \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new ReplaceTabsWithSpacesFilter ())->filter ($ this ->testString ));
90
+ $ this ->assertEquals (" & haha 13 <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\n \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new ReplaceTabsWithSpacesFilter ())->filter ($ this ->testString ));
90
91
}
91
92
92
93
public function testLimitConsecutiveUnixNewlinesFilter (): void
93
94
{
94
- $ this ->assertEquals (" & haha <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new LimitConsecutiveUnixNewlinesFilter ())->filter ($ this ->testString ));
95
+ $ this ->assertEquals (" & haha 13 <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new LimitConsecutiveUnixNewlinesFilter ())->filter ($ this ->testString ));
95
96
}
96
97
97
98
public function testReplaceUnicodeWhitespaces (): void
98
99
{
99
- $ this ->assertEquals (" & haha <strong>many</strong> grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new ReplaceUnicodeWhitespacesFilter ())->filter ($ this ->testString ));
100
+ $ this ->assertEquals (" & haha 13 <strong>many</strong> grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new ReplaceUnicodeWhitespacesFilter ())->filter ($ this ->testString ));
100
101
}
101
102
102
103
public function testLowercase (): void
103
104
{
104
- $ this ->assertEquals (" & haha <strong>many</strong> grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\ thing contained!!!™ " , (new LowercaseFilter ())->filter ($ this ->testString ));
105
+ $ this ->assertEquals (" & haha 13 <strong>many</strong> grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\ thing contained!!!™ " , (new LowercaseFilter ())->filter ($ this ->testString ));
105
106
}
106
107
107
108
public function testUppercase (): void
108
109
{
109
- $ this ->assertEquals (" & HAHA <STRONG>MANY</STRONG> &NBSP; GRÜSS GÖTTER \r\n\n\n\t \n \n <INVALID> \"L'ETAT \"\ THING CONTAINED!!!™ " , (new UppercaseFilter ())->filter ($ this ->testString ));
110
+ $ this ->assertEquals (" & HAHA 13 <STRONG>MANY</STRONG> &NBSP; GRÜSS GÖTTER \r\n\n\n\t \n \n <INVALID> \"L'ETAT \"\ THING CONTAINED!!!™ " , (new UppercaseFilter ())->filter ($ this ->testString ));
110
111
}
111
112
112
113
public function testUppercaseWordsFirstCharacter (): void
113
114
{
114
- $ this ->assertEquals (" &Amp; Haha <Strong>Many</Strong> &Nbsp; Grüss Götter \r\n\n\n\t \n \n <Invalid> \"L'Etat \"\ Thing Contained!!!&Trade; " , (new UppercaseWordsFirstCharacterFilter ())->filter ($ this ->testString ));
115
+ $ this ->assertEquals (" &Amp; Haha 13 <Strong>Many</Strong> &Nbsp; Grüss Götter \r\n\n\n\t \n \n <Invalid> \"L'Etat \"\ Thing Contained!!!&Trade; " , (new UppercaseWordsFirstCharacterFilter ())->filter ($ this ->testString ));
115
116
}
116
117
117
118
public function testUppercaseFirstCharacter (): void
118
119
{
119
- $ this ->assertEquals (" & haha <strong>many</strong> grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\ thing contained!!!™ " , (new UppercaseFirstCharacterFilter ())->filter ($ this ->testString ));
120
+ $ this ->assertEquals (" & haha 13 <strong>many</strong> grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\ thing contained!!!™ " , (new UppercaseFirstCharacterFilter ())->filter ($ this ->testString ));
120
121
}
121
122
122
123
public function testTrim (): void
123
124
{
124
- $ this ->assertEquals ("& haha <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new TrimFilter ())->filter ($ this ->testString ));
125
+ $ this ->assertEquals ("& haha 13 <strong>many</strong> \xc2\xa0 grüss götter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new TrimFilter ())->filter ($ this ->testString ));
125
126
}
126
127
127
128
public function testRemoveNonUTF8Characters (): void
128
129
{
129
130
$ nonUTF8 = utf8_decode ($ this ->testString );
130
131
131
- $ this ->assertEquals (" & haha <strong>many</strong> grss gtter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new RemoveNonUTF8CharactersFilter ())->filter ($ nonUTF8 ));
132
+ $ this ->assertEquals (" & haha 13 <strong>many</strong> grss gtter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , (new RemoveNonUTF8CharactersFilter ())->filter ($ nonUTF8 ));
132
133
}
133
134
134
135
public function testWrapLongWordsNoHTML (): void
@@ -163,17 +164,23 @@ public function testWrapLongWordsWithHTML(): void
163
164
164
165
public function testRemoveNonAlphanumeric (): void
165
166
{
166
- $ this ->assertEquals ('amphahastrongmanystrongnbspgrssgtterinvalidletatthingcontainedtrade ' , (new RemoveNonAlphanumericFilter ())->filter ($ this ->testString ));
167
+ $ this ->assertEquals ('amphaha13strongmanystrongnbspgrssgtterinvalidletatthingcontainedtrade ' , (new RemoveNonAlphanumericFilter ())->filter ($ this ->testString ));
168
+ }
169
+
170
+ public function testRemoveNonAlphabetic (): void
171
+ {
172
+ $ this ->assertEquals ('amphahastrongmanystrongnbspgrssgtterinvalidletatthingcontainedtrade ' , (new RemoveNonAlphabeticFilter ())->filter ($ this ->testString ));
167
173
}
168
174
169
175
public function testRemoveNonNumeric (): void
170
176
{
171
177
$ this ->assertEquals ('4513 ' , (new RemoveNonNumericFilter ())->filter ('hallö 45 dadaismus! <huhu> 1/3 ' ));
178
+ $ this ->assertEquals ('13 ' , (new RemoveNonNumericFilter ())->filter ($ this ->testString ));
172
179
}
173
180
174
181
public function testReplaceNonAlphanumeric (): void
175
182
{
176
- $ this ->assertEquals ('-amp-haha-strong-many-strong-nbsp-gr-ss-g-tter-invalid-l-etat-thing-contained-trade- ' , (new ReplaceNonAlphanumericFilter ())->filter ($ this ->testString ));
183
+ $ this ->assertEquals ('-amp-haha-13- strong-many-strong-nbsp-gr-ss-g-tter-invalid-l-etat-thing-contained-trade- ' , (new ReplaceNonAlphanumericFilter ())->filter ($ this ->testString ));
177
184
}
178
185
179
186
public function testUrlFriendly (): void
@@ -184,12 +191,12 @@ public function testUrlFriendly(): void
184
191
$ string = (new ReplaceNonAlphanumericFilter ())->filter ($ string );
185
192
$ string = (new TrimFilter ('- ' ))->filter ($ string );
186
193
187
- $ this ->assertEquals ('haha-strong-many-strong-nbsp-gruss-gotter-invalid-l-etat-thing-contained-trade ' , $ string );
194
+ $ this ->assertEquals ('haha-13- strong-many-strong-nbsp-gruss-gotter-invalid-l-etat-thing-contained-trade ' , $ string );
188
195
}
189
196
190
197
public function testRemoveNonAsciiAndControlCharacters (): void
191
198
{
192
- $ this ->assertEquals (' & haha <strong>many</strong> grss gtter <invalid>"l \'etat" \\ thing contained!!!™ ' , (new RemoveNonAsciiAndControlCharactersFilter ())->filter ($ this ->testString ));
199
+ $ this ->assertEquals (' & haha 13 <strong>many</strong> grss gtter <invalid>"l \'etat" \\ thing contained!!!™ ' , (new RemoveNonAsciiAndControlCharactersFilter ())->filter ($ this ->testString ));
193
200
}
194
201
195
202
public function testDecodeBasicHTMLEntitiesAndStreamlineInputWithNewlines (): void
@@ -198,15 +205,15 @@ public function testDecodeBasicHTMLEntitiesAndStreamlineInputWithNewlines(): voi
198
205
$ string = (new DecodeBasicHTMLEntitiesFilter ())->filter ($ string );
199
206
$ string = (new StreamlineInputWithNewlinesFilter ())->filter ($ string );
200
207
201
- $ this ->assertEquals ("& haha <strong>many</strong> grüss götter \n\n<invalid> \"l'etat \"\\ thing contained!!!™ " , $ string );
208
+ $ this ->assertEquals ("& haha 13 <strong>many</strong> grüss götter \n\n<invalid> \"l'etat \"\\ thing contained!!!™ " , $ string );
202
209
}
203
210
204
211
public function testStreamlineInputNoNewlines (): void
205
212
{
206
213
$ string = $ this ->testString ;
207
214
$ string = (new StreamlineInputNoNewlinesFilter ())->filter ($ string );
208
215
209
- $ this ->assertEquals ("& haha <strong>many</strong> grüss götter <invalid> \"l'etat \"\\ thing contained!!!™ " , $ string );
216
+ $ this ->assertEquals ("& haha 13 <strong>many</strong> grüss götter <invalid> \"l'etat \"\\ thing contained!!!™ " , $ string );
210
217
}
211
218
212
219
public function testReplaceNewlinesWithParagraphsAndBreaks (): void
@@ -222,14 +229,14 @@ public function testEncodeBasicHTMLEntities(): void
222
229
{
223
230
$ string = (new EncodeBasicHTMLEntitiesFilter ())->filter ($ this ->testString );
224
231
225
- $ this ->assertEquals (" &amp; haha <strong>many</strong> \xc2\xa0 &nbsp; grüss götter \r\n\n\n\t \n \n <invalid>"l'etat" \\ thing contained!!!&trade; " , $ string );
232
+ $ this ->assertEquals (" &amp; haha 13 <strong>many</strong> \xc2\xa0 &nbsp; grüss götter \r\n\n\n\t \n \n <invalid>"l'etat" \\ thing contained!!!&trade; " , $ string );
226
233
}
227
234
228
235
public function testNormalizeLettersToAscii (): void
229
236
{
230
237
$ string = (new NormalizeLettersToAsciiFilter ())->filter ($ this ->testString );
231
238
232
- $ this ->assertEquals (" & haha <strong>many</strong> \xc2\xa0 gruss gotter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , $ string );
239
+ $ this ->assertEquals (" & haha 13 <strong>many</strong> \xc2\xa0 gruss gotter \r\n\n\n\t \n \n <invalid> \"l'etat \"\\ thing contained!!!™ " , $ string );
233
240
}
234
241
235
242
public function testSnakeCaseToCamelCase (): void
@@ -373,7 +380,7 @@ public function testTrimUnicode(): void
373
380
374
381
public function testRemoveHTMLCharacters (): void
375
382
{
376
- $ this ->assertEquals (" & haha strongmany /strong \xc2\xa0 grüss götter \r\n\n\n\t \n \n invalidl'etat \\ thing contained!!!™ " , (new RemoveHTMLTagCharacters ())->filter ($ this ->testString ));
383
+ $ this ->assertEquals (" & haha 13strongmany /strong \xc2\xa0 grüss götter \r\n\n\n\t \n \n invalidl'etat \\ thing contained!!!™ " , (new RemoveHTMLTagCharacters ())->filter ($ this ->testString ));
377
384
}
378
385
379
386
public function testEmailStreamline (): void
0 commit comments