Skip to content

Commit a5cd71d

Browse files
committed
[Fixed][api] Path is appended twice to API base URI
1 parent c9067e2 commit a5cd71d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
### Removed
1515

1616
### Fixed
17+
- [Api] path is appended twice to API base URI.
1718

1819
### Security
1920

src/Api/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function put($path, array $data)
161161
*/
162162
public function request($method, $path, array $data = null)
163163
{
164-
$uri = $this->apiBaseUri . '/' . ltrim($path, '/') . $path;
164+
$uri = $this->apiBaseUri . '/' . ltrim($path, '/');
165165

166166
$request = new ApiRequest($this->useSandbox, $this->accessToken, $method, $uri, $data);
167167
try {

test/Api/ClientTest.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ public function testSuccessRequest()
1414
{
1515
$httpClient = $this->getMock('Aplazame\\Http\\ClientInterface');
1616
$httpClient->method('send')
17-
->willReturn(new Response(200, '{"foo": "value"}'))
17+
->willReturnCallback(function (ApiRequest $apiRequest) {
18+
ClientTest::assertEquals('GET', $apiRequest->getMethod(), 'getMethod not match');
19+
ClientTest::assertEquals('http://api.example.com/path', $apiRequest->getUri(), 'getUri not match');
20+
21+
$headers = $apiRequest->getHeaders();
22+
ClientTest::assertEquals('application/vnd.aplazame.sandbox.v1+json', $headers['Accept'][0], 'Accept header not match');
23+
ClientTest::assertEquals('Bearer fooAccessToken', $headers['Authorization'][0], 'Authorization header not match');
24+
25+
return new Response(200, '{"foo": "value"}');
26+
})
1827
;
1928

2029
$client = new Client(
@@ -24,7 +33,7 @@ public function testSuccessRequest()
2433
$httpClient
2534
);
2635

27-
$response = $client->request('get', 'uri');
36+
$response = $client->request('get', '/path');
2837

2938
self::assertEquals(array('foo' => 'value'), $response);
3039
}

0 commit comments

Comments
 (0)