Skip to content

Commit 73afc65

Browse files
authored
Merge pull request #20 from php-http/patch-uri
Adding tests from UriInterface
2 parents 8333edc + 196c7fe commit 73afc65

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

src/UriIntegrationTest.php

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,30 +108,72 @@ public function testPort()
108108
$this->assertEquals(81, $uri->getPort());
109109
}
110110

111-
public function testPath()
111+
/**
112+
* @dataProvider getPaths
113+
*/
114+
public function testPath(UriInterface $uri, $expected)
112115
{
113116
if (isset($this->skippedTests[__FUNCTION__])) {
114117
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
115118
}
116119

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+
];
118133
}
119134

120-
public function testQuery()
135+
/**
136+
* @dataProvider getQueries
137+
*/
138+
public function testQuery(UriInterface $uri, $expected)
121139
{
122140
if (isset($this->skippedTests[__FUNCTION__])) {
123141
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
124142
}
125143

126-
// TODO
144+
$this->assertEquals($expected, $uri->getQuery());
127145
}
128146

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)
130162
{
131163
if (isset($this->skippedTests[__FUNCTION__])) {
132164
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
133165
}
134166

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+
];
136178
}
137179
}

0 commit comments

Comments
 (0)