Skip to content

Commit 457d0ad

Browse files
committed
Removed extra slash after enterprise URL
This will fix #511
1 parent 4a06d34 commit 457d0ad

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/Github/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ private function setEnterpriseUrl($enterpriseUrl)
315315
$builder->removePlugin(PathPrepend::class);
316316

317317
$builder->addPlugin(new Plugin\AddHostPlugin(UriFactoryDiscovery::find()->createUri($enterpriseUrl)));
318-
$builder->addPlugin(new PathPrepend(sprintf('/api/%s/', $this->getApiVersion())));
318+
$builder->addPlugin(new PathPrepend(sprintf('/api/%s', $this->getApiVersion())));
319319
}
320320

321321
/**

test/Github/Tests/ClientTest.php

+24
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
use Github\Exception\BadMethodCallException;
88
use Github\HttpClient\Builder;
99
use Github\HttpClient\Plugin\Authentication;
10+
use GuzzleHttp\Psr7\Response;
1011
use Http\Client\Common\Plugin;
12+
use Http\Client\HttpClient;
13+
use Psr\Http\Message\RequestInterface;
1114

1215
class ClientTest extends \PHPUnit_Framework_TestCase
1316
{
@@ -205,4 +208,25 @@ public function getApiClassesProvider()
205208
array('meta', Api\Meta::class)
206209
);
207210
}
211+
212+
/**
213+
* Make sure that the URL is correct when using enterprise.
214+
*/
215+
public function testEnterpriseUrl()
216+
{
217+
$httpClientMock = $this->getMockBuilder(HttpClient::class)
218+
->setMethods(['sendRequest'])
219+
->getMock();
220+
221+
$httpClientMock->expects($this->once())
222+
->method('sendRequest')
223+
->with($this->callback(function(RequestInterface $request) {
224+
return (string) $request->getUri() === 'https://foobar.com/api/v3/enterprise/stats/all';
225+
}))
226+
->willReturn(new Response(200, [], '[]'));
227+
228+
$httpClientBuilder = new Builder($httpClientMock);
229+
$client = new Client($httpClientBuilder, null, 'https://foobar.com');
230+
$client->enterprise()->stats()->show('all');
231+
}
208232
}

0 commit comments

Comments
 (0)