Skip to content

Commit 2354dce

Browse files
committed
Add method to use generate release notes endpoint
1 parent 83b8a32 commit 2354dce

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

lib/Github/Api/Repository/Releases.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,20 @@ public function show($username, $repository, $id)
6868
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id);
6969
}
7070

71+
/**
72+
* Generate release notes content for a release.
73+
*
74+
* @param string $username
75+
* @param string $repository
76+
* @param array $params
77+
*
78+
* @return array
79+
*/
80+
public function generateNotes($username, $repository, array $params)
81+
{
82+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/generate-notes', $params);
83+
}
84+
7185
/**
7286
* Create new release in selected repository.
7387
*

test/Github/Tests/Api/Repository/ReleasesTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,26 @@ public function shouldGetSingleRepositoryRelease()
7676
$this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', $id));
7777
}
7878

79+
/**
80+
* @test
81+
*/
82+
public function shouldGenerateReleaseNotes()
83+
{
84+
$expectedValue = [
85+
'name' => 'Release v1.0.0 is now available!',
86+
'body' => '##Changes in Release v1.0.0 ... ##Contributors @monalisa',
87+
];
88+
$data = ['tag_name' => 'some-tag'];
89+
90+
$api = $this->getApiMock();
91+
$api->expects($this->once())
92+
->method('post')
93+
->with('/repos/KnpLabs/php-github-api/releases/generate-notes')
94+
->will($this->returnValue($expectedValue));
95+
96+
$this->assertEquals($expectedValue, $api->generateNotes('KnpLabs', 'php-github-api', $data));
97+
}
98+
7999
/**
80100
* @test
81101
*/

0 commit comments

Comments
 (0)