-
-
Notifications
You must be signed in to change notification settings - Fork 594
/
PathPrependTest.php
39 lines (33 loc) · 1 KB
/
PathPrependTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Github\Tests\HttpClient\Plugin;
use Github\HttpClient\Plugin\PathPrepend;
use GuzzleHttp\Psr7\Request;
use PHPUnit\Framework\TestCase;
/**
* @author Nils Adermann <naderman@naderman.de>
*/
class PathPrependTest extends TestCase
{
/**
* @dataProvider uris
*/
public function testPathIsPrepended($uri, $expectedPath)
{
$request = new Request('GET', $uri);
$plugin = new PathPrepend('/api/v3');
$newRequest = null;
$plugin->doHandleRequest($request, function ($request) use (&$newRequest) {
$newRequest = $request;
}, function () {
throw new \RuntimeException('Did not expect plugin to call first');
});
$this->assertEquals($expectedPath, $newRequest->getUri()->getPath());
}
public static function uris()
{
return [
['http://example.com/foo/bar/api', '/api/v3/foo/bar/api'],
['http://example.com/api/v3/foo/bar/api', '/api/v3/foo/bar/api'],
];
}
}