Skip to content

Commit

Permalink
Add tests and documentation for the mergeUpstream method
Browse files Browse the repository at this point in the history
  • Loading branch information
DAGpro committed Oct 23, 2022
1 parent c6b2d39 commit 06e6c9b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/repos.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ $repository = $client->api('repo')->forks()->create('ornicar', 'php-github-api')

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

### Merge upstream repository

> Requires [authentication](security.md).
```php
$repository = $client->api('repo')->mergeUpstream('ornicar', 'php-github-api', 'branchName');
```
Merge upstream a branch of a forked repository to keep it up-to-date with the upstream repository.

### Get the tags of a repository

```php
Expand Down
20 changes: 20 additions & 0 deletions test/Github/Tests/Api/RepoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,26 @@ public function shouldGetRepositoryBranch()
$this->assertEquals($expectedArray, $api->branches('KnpLabs', 'php-github-api', 'master'));
}

/**
* @test
*/
public function shouldMergeUpstreamRepository()
{
$expectedArray = [
'message' => 'Successfully fetched and fast-forwarded from upstream upstreamRepo:main',
'merge_type' => 'fast-forward',
'merge_branch' => 'upstreamRepo:main',
];

$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with('/repos/KnpLabs/php-github-api/merge-upstream', ['branch' => 'main'])
->will($this->returnValue($expectedArray));

$this->assertEquals($expectedArray, $api->mergeUpstream('KnpLabs', 'php-github-api', 'main'));
}

/**
* @test
*/
Expand Down

0 comments on commit 06e6c9b

Please sign in to comment.