@@ -163,4 +163,38 @@ public function testAttributes()
163
163
$ matcher ->matchAttribute ('foo ' , 'babar ' );
164
164
$ this ->assertFalse ($ matcher ->matches ($ request ));
165
165
}
166
+
167
+ public function testIps ()
168
+ {
169
+ $ matcher = new RequestMatcher ();
170
+
171
+ $ request = Request::create ('' , 'GET ' , [], [], [], ['REMOTE_ADDR ' => '127.0.0.1 ' ]);
172
+
173
+ $ matcher ->matchIp ('127.0.0.1 ' );
174
+ $ this ->assertTrue ($ matcher ->matches ($ request ));
175
+
176
+ $ matcher ->matchIp ('192.168.0.1 ' );
177
+ $ this ->assertFalse ($ matcher ->matches ($ request ));
178
+
179
+ $ matcher ->matchIps ('127.0.0.1 ' );
180
+ $ this ->assertTrue ($ matcher ->matches ($ request ));
181
+
182
+ $ matcher ->matchIps ('127.0.0.1, ::1 ' );
183
+ $ this ->assertTrue ($ matcher ->matches ($ request ));
184
+
185
+ $ matcher ->matchIps ('192.168.0.1, ::1 ' );
186
+ $ this ->assertFalse ($ matcher ->matches ($ request ));
187
+
188
+ $ matcher ->matchIps (['127.0.0.1 ' , '::1 ' ]);
189
+ $ this ->assertTrue ($ matcher ->matches ($ request ));
190
+
191
+ $ matcher ->matchIps (['192.168.0.1 ' , '::1 ' ]);
192
+ $ this ->assertFalse ($ matcher ->matches ($ request ));
193
+
194
+ $ matcher ->matchIps (['1.1.1.1 ' , '2.2.2.2 ' , '127.0.0.1, ::1 ' ]);
195
+ $ this ->assertTrue ($ matcher ->matches ($ request ));
196
+
197
+ $ matcher ->matchIps (['1.1.1.1 ' , '2.2.2.2 ' , '192.168.0.1, ::1 ' ]);
198
+ $ this ->assertFalse ($ matcher ->matches ($ request ));
199
+ }
166
200
}
0 commit comments