@@ -16,7 +16,7 @@ public function testShouldPassWhenValidUrlGiven($url)
16
16
$ this ->assertTrue ($ regex ->test ($ url ));
17
17
}
18
18
19
- static public function provideValidUrls ()
19
+ public static function provideValidUrls ()
20
20
{
21
21
return array (
22
22
array ('http://github.com ' ),
@@ -40,7 +40,7 @@ public function testShouldFailWithInvalidUrls($url)
40
40
$ this ->assertFalse ($ regex ->test ($ url ));
41
41
}
42
42
43
- static public function provideInvalidUrls ()
43
+ public static function provideInvalidUrls ()
44
44
{
45
45
return array (
46
46
array (' http://github.com ' ),
@@ -61,4 +61,163 @@ protected function buildUrlPattern(VerbalExpressions $regex)
61
61
->anythingBut (" " )
62
62
->endOfLine ();
63
63
}
64
+
65
+ public function testThenAfterStartOfLine ()
66
+ {
67
+ $ regex = new VerbalExpressions ();
68
+ $ regex ->startOfLine ()
69
+ ->then ('a ' )
70
+ ->endOfLine ();
71
+
72
+ $ this ->assertTrue ($ regex ->test ('a ' ));
73
+ $ this ->assertFalse ($ regex ->test ('ba ' ));
74
+ }
75
+
76
+ public function testThenSomewhere ()
77
+ {
78
+ $ regex = new VerbalExpressions ();
79
+ $ regex ->startOfLine (false )
80
+ ->then ('a ' )
81
+ ->endOfLine (false );
82
+
83
+ $ this ->assertTrue ($ regex ->test ('a ' ));
84
+ $ this ->assertTrue ($ regex ->test ('ba ' ));
85
+ }
86
+
87
+ /**
88
+ * @dataProvider provideAnything
89
+ */
90
+ public function testAnything ($ needle )
91
+ {
92
+ $ regex = new VerbalExpressions ();
93
+ $ regex ->startOfLine ()
94
+ ->anything ()
95
+ ->endOfLine ();
96
+
97
+ $ this ->assertTrue ($ regex ->test ($ needle ));
98
+ }
99
+
100
+ public static function provideAnything ()
101
+ {
102
+ return array (
103
+ array ('a ' ),
104
+ array ('foo ' ),
105
+ array ('bar ' ),
106
+ array ('! ' ),
107
+ array (' dfs fdslf sdlfk ' ),
108
+ array ('t ( - _ - t ) ' ),
109
+ );
110
+ }
111
+
112
+ public function testAnythingBut ()
113
+ {
114
+ $ regex = new VerbalExpressions ();
115
+ $ regex ->startOfLine ()
116
+ ->anythingBut ('a ' )
117
+ ->endOfLine ();
118
+
119
+ $ this ->assertTrue ($ regex ->test ('bcdefg h I A ' ));
120
+ $ this ->assertFalse ($ regex ->test ('a ' ));
121
+ $ this ->assertFalse ($ regex ->test ('fooa ' ));
122
+ }
123
+
124
+ public function testAnythingButQuote ()
125
+ {
126
+ $ regex = new VerbalExpressions ();
127
+ $ regex ->startOfLine ()
128
+ ->anythingBut ('[ ' )
129
+ ->endOfLine ();
130
+
131
+ $ this ->assertTrue ($ regex ->test ('abcd ' ));
132
+ $ this ->assertTrue ($ regex ->test ('ab\cd ' ));
133
+ $ this ->assertFalse ($ regex ->test ('ab[cd ' ));
134
+ $ this ->assertFalse ($ regex ->test ('[ ' ));
135
+ $ this ->assertFalse ($ regex ->test ('[ ' ));
136
+ $ this ->assertFalse ($ regex ->test ('\[ ' ));
137
+ }
138
+
139
+ public function testSomething ()
140
+ {
141
+ $ regex = new VerbalExpressions ();
142
+ $ regex ->startOfLine ()
143
+ ->something ()
144
+ ->endOfLine ();
145
+
146
+ $ this ->assertTrue ($ regex ->test ('foobar ' ));
147
+ $ this ->assertTrue ($ regex ->test ('foobar! ' ));
148
+ $ this ->assertTrue ($ regex ->test ('foo bar ' ));
149
+ $ this ->assertFalse ($ regex ->test ('' ));
150
+ }
151
+
152
+ public function testSomethingBut ()
153
+ {
154
+ $ regex = new VerbalExpressions ();
155
+ $ regex ->startOfLine ()
156
+ ->somethingBut ('a ' )
157
+ ->endOfLine ();
158
+
159
+ $ this ->assertTrue ($ regex ->test ('foobr ' ));
160
+ $ this ->assertTrue ($ regex ->test ('foobr! ' ));
161
+ $ this ->assertTrue ($ regex ->test ('foo br ' ));
162
+ $ this ->assertFalse ($ regex ->test ('a ' ));
163
+ $ this ->assertFalse ($ regex ->test ('bar ' ));
164
+ $ this ->assertFalse ($ regex ->test ('foo bar ' ));
165
+ $ this ->assertFalse ($ regex ->test ('' ));
166
+ }
167
+
168
+ public function testLineBreak ()
169
+ {
170
+ $ regex = new VerbalExpressions ();
171
+ $ regex ->startOfLine ()
172
+ ->something ()
173
+ ->lineBreak ()
174
+ ->something ()
175
+ ->endOfLine ();
176
+
177
+ $ this ->assertTrue ($ regex ->test ("foo \nbar " ));
178
+ $ this ->assertFalse ($ regex ->test ("foo bar " ));
179
+ }
180
+
181
+ public function testTab ()
182
+ {
183
+ $ regex = new VerbalExpressions ();
184
+ $ regex ->startOfLine ()
185
+ ->something ()
186
+ ->tab ()
187
+ ->something ()
188
+ ->endOfLine ();
189
+
190
+ $ this ->assertTrue ($ regex ->test ("foo \tbar " ));
191
+ $ this ->assertFalse ($ regex ->test ("foo bar " ));
192
+ }
193
+
194
+ public function testWord ()
195
+ {
196
+ $ regex = new VerbalExpressions ();
197
+ $ regex ->startOfLine ()
198
+ ->word ()
199
+ ->endOfLine ();
200
+
201
+ $ this ->assertTrue ($ regex ->test ('abcdefghijklmnopqrstuvwxyz0123456789_ ' ));
202
+ $ this ->assertTrue ($ regex ->test ('ABCDEFGHIJKLMNOPQRSTUVWXYZ ' ));
203
+ $ this ->assertTrue ($ regex ->test ('a_c ' ));
204
+ $ this ->assertFalse ($ regex ->test ('a-b ' ));
205
+ $ this ->assertFalse ($ regex ->test ('a b ' ));
206
+ $ this ->assertFalse ($ regex ->test ('a!b ' ));
207
+ }
208
+
209
+ public function testAnyOf ()
210
+ {
211
+ $ regex = new VerbalExpressions ();
212
+ $ regex ->startOfLine ()
213
+ ->anyOf ('a1M ' )
214
+ ->endOfLine ();
215
+
216
+ $ this ->assertTrue ($ regex ->test ('a ' ));
217
+ $ this ->assertTrue ($ regex ->test ('1 ' ));
218
+ $ this ->assertTrue ($ regex ->test ('M ' ));
219
+ $ this ->assertFalse ($ regex ->test ('b ' ));
220
+ $ this ->assertFalse ($ regex ->test ('' ));
221
+ $ this ->assertFalse ($ regex ->test (' ' ));
222
+ }
64
223
}
0 commit comments