@@ -108,30 +108,72 @@ public function testPort()
108
108
$ this ->assertEquals (81 , $ uri ->getPort ());
109
109
}
110
110
111
- public function testPath ()
111
+ /**
112
+ * @dataProvider getPaths
113
+ */
114
+ public function testPath (UriInterface $ uri , $ expected )
112
115
{
113
116
if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
114
117
$ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
115
118
}
116
119
117
- // TODO
120
+ $ this ->assertEquals ($ expected , $ uri ->getPath ());
121
+ }
122
+
123
+ public function getPaths ()
124
+ {
125
+ return [
126
+ [$ this ->createUri ('http://www.foo.com/ ' ), '/ ' ],
127
+ [$ this ->createUri ('http://www.foo.com ' ), '' ],
128
+ [$ this ->createUri ('foo/bar ' ), 'foo/bar ' ],
129
+ [$ this ->createUri ('http://www.foo.com/foo bar ' ), '/foo%20bar ' ],
130
+ [$ this ->createUri ('http://www.foo.com/foo%20bar ' ), '/foo%20bar ' ],
131
+ [$ this ->createUri ('http://www.foo.com/foo%2fbar ' ), '/foo%2fbar ' ],
132
+ ];
118
133
}
119
134
120
- public function testQuery ()
135
+ /**
136
+ * @dataProvider getQueries
137
+ */
138
+ public function testQuery (UriInterface $ uri , $ expected )
121
139
{
122
140
if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
123
141
$ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
124
142
}
125
143
126
- // TODO
144
+ $ this -> assertEquals ( $ expected , $ uri -> getQuery ());
127
145
}
128
146
129
- public function testFragment ()
147
+ public function getQueries ()
148
+ {
149
+ return [
150
+ [$ this ->createUri ('http://www.foo.com ' ), '' ],
151
+ [$ this ->createUri ('http://www.foo.com? ' ), '' ],
152
+ [$ this ->createUri ('http://www.foo.com?foo=bar ' ), 'foo=bar ' ],
153
+ [$ this ->createUri ('http://www.foo.com?foo=bar%26baz ' ), 'foo=bar%26baz ' ],
154
+ [$ this ->createUri ('http://www.foo.com?foo=bar&baz=biz ' ), 'foo=bar&baz=biz ' ],
155
+ ];
156
+ }
157
+
158
+ /**
159
+ * @dataProvider getFragments
160
+ */
161
+ public function testFragment (UriInterface $ uri , $ expected )
130
162
{
131
163
if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
132
164
$ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
133
165
}
134
166
135
- // TODO
167
+ $ this ->assertEquals ($ expected , $ uri ->getFragment ());
168
+ }
169
+
170
+ public function getFragments ()
171
+ {
172
+ return [
173
+ [$ this ->createUri ('http://www.foo.com ' ), '' ],
174
+ [$ this ->createUri ('http://www.foo.com# ' ), '' ],
175
+ [$ this ->createUri ('http://www.foo.com#foo ' ), 'foo ' ],
176
+ [$ this ->createUri ('http://www.foo.com#foo%20bar ' ), 'foo%20bar ' ],
177
+ ];
136
178
}
137
179
}
0 commit comments