Skip to content

Commit b6ede6c

Browse files
committed
Add tests and documentation for the mergeUpstream method
1 parent c6b2d39 commit b6ede6c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

doc/repos.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,15 @@ $repository = $client->api('repo')->forks()->create('ornicar', 'php-github-api')
223223

224224
Creates a fork of the 'php-github-api' owned by 'ornicar' and returns the newly created repository.
225225

226+
### Merge upstream repository
227+
228+
> Requires [authentication](security.md).
229+
230+
```php
231+
$repository = $client->api('repo')->mergeUpstream('ornicar', 'php-github-api', 'branchName');
232+
```
233+
Merge upstream a branch of a forked repository to keep it up-to-date with the upstream repository.
234+
226235
### Get the tags of a repository
227236

228237
```php

test/Github/Tests/Api/RepoTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,26 @@ public function shouldGetRepositoryBranch()
240240
$this->assertEquals($expectedArray, $api->branches('KnpLabs', 'php-github-api', 'master'));
241241
}
242242

243+
/**
244+
* @test
245+
*/
246+
public function shouldMergeUpstreamRepository()
247+
{
248+
$expectedArray = [
249+
'message' => 'Successfully fetched and fast-forwarded from upstream upstreamRepo:main',
250+
'merge_type' => 'fast-forward',
251+
'merge_branch' => 'upstreamRepo:main'
252+
];
253+
254+
$api = $this->getApiMock();
255+
$api->expects($this->once())
256+
->method('post')
257+
->with('/repos/KnpLabs/php-github-api/merge-upstream', ['branch' => 'main'])
258+
->will($this->returnValue($expectedArray));
259+
260+
$this->assertEquals($expectedArray, $api->mergeUpstream('KnpLabs', 'php-github-api', 'main'));
261+
}
262+
243263
/**
244264
* @test
245265
*/

0 commit comments

Comments
 (0)