Skip to content

Commit 1568c49

Browse files
Alexander Viktorkinvimishor
Alexander Viktorkin
authored andcommitted
Merged in sancho67/bitbucket-api/fix_api2_fork (pull request #46)
Updated create fork to API 2.0
1 parent c861336 commit 1568c49

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

lib/Bitbucket/API/Repositories/Repository.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,12 @@ public function fork($account, $repo, $name, array $params = array())
196196
{
197197
$params['name'] = $name;
198198

199-
return $this->requestPost(
200-
sprintf('repositories/%s/%s/fork', $account, $repo),
201-
$params
199+
$params = json_encode($params);
200+
201+
return $this->getClient()->setApiVersion('2.0')->post(
202+
sprintf('repositories/%s/%s/forks', $account, $repo),
203+
$params,
204+
array('Content-Type' => 'application/json')
202205
);
203206
}
204207

test/Bitbucket/Tests/API/Repositories/RepositoryTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,22 @@ public function testGetRepositoryForks()
223223

224224
public function testForkRepositorySuccess()
225225
{
226-
$endpoint = 'repositories/gentle/eof/fork';
226+
$endpoint = 'repositories/gentle/eof/forks';
227227
$params = array(
228-
'name' => 'my-eof',
229228
'is_private' => true,
229+
'name' => 'my-eof',
230230
);
231231

232-
$repository = $this->getApiMock('Bitbucket\API\Repositories\Repository');
233-
$repository->expects($this->once())
234-
->method('requestPost')
235-
->with($endpoint, $params);
232+
$client = $this->getHttpClientMock();
233+
$client->expects($this->once())
234+
->method('post')
235+
->with($endpoint, json_encode($params));
236+
237+
/** @var \Bitbucket\API\Repositories\Repository $repo */
238+
$repo = $this->getClassMock('Bitbucket\API\Repositories\Repository', $client);
236239

237240
/** @var $repository \Bitbucket\API\Repositories\Repository */
238-
$repository->fork('gentle', 'eof', 'my-eof', array('is_private' => true));
241+
$repo->fork('gentle', 'eof', 'my-eof', array('is_private' => true));
239242
}
240243

241244
public function testGetBranches()

0 commit comments

Comments
 (0)