Skip to content

Commit

Permalink
Add method to use generate release notes endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jul 9, 2022
1 parent 83b8a32 commit 2354dce
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/Github/Api/Repository/Releases.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ public function show($username, $repository, $id)
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id);
}

/**
* Generate release notes content for a release.
*
* @param string $username
* @param string $repository
* @param array $params
*
* @return array
*/
public function generateNotes($username, $repository, array $params)
{
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/generate-notes', $params);
}

/**
* Create new release in selected repository.
*
Expand Down
20 changes: 20 additions & 0 deletions test/Github/Tests/Api/Repository/ReleasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ public function shouldGetSingleRepositoryRelease()
$this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', $id));
}

/**
* @test
*/
public function shouldGenerateReleaseNotes()
{
$expectedValue = [
'name' => 'Release v1.0.0 is now available!',
'body' => '##Changes in Release v1.0.0 ... ##Contributors @monalisa',
];
$data = ['tag_name' => 'some-tag'];

$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with('/repos/KnpLabs/php-github-api/releases/generate-notes')
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->generateNotes('KnpLabs', 'php-github-api', $data));
}

/**
* @test
*/
Expand Down

0 comments on commit 2354dce

Please sign in to comment.