File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed
lib/Github/Api/Repository
test/Github/Tests/Api/Repository Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 33
44This Github API Endpoint is currently undocumented because it's new, but works just fine.
55
6+ ### Get latest actual release
7+
8+ ``` php
9+ $release = $client->api('repo')->releases()->latest('twbs', 'bootstrap');
10+ ```
11+
12+ ### List releases for a tag
13+
14+ ``` php
15+ $release = $client->api('repo')->releases()->all('twbs', 'bootstrap', 'd890eec');
16+ ```
617
718### List all releases
819
Original file line number Diff line number Diff line change 1212 */
1313class Releases extends AbstractApi
1414{
15+ /**
16+ * Get the latest release.
17+ *
18+ * @param $username
19+ * @param $repository
20+ *
21+ * @return array
22+ */
23+ public function latest ($ username , $ repository )
24+ {
25+ return $ this ->get ('repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/releases/latest ' );
26+ }
27+
28+ /**
29+ * List releases for a tag.
30+ *
31+ * @param $username
32+ * @param $repository
33+ * @param $tag
34+ *
35+ * @return array
36+ */
37+ public function tag ($ username , $ repository , $ tag )
38+ {
39+ return $ this ->get ('repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/releases/tags/ ' .rawurlencode ($ tag ));
40+ }
41+
1542 /**
1643 * List releases in selected repository.
1744 *
Original file line number Diff line number Diff line change 66
77class ReleasesTest extends TestCase
88{
9+ /**
10+ * @test
11+ */
12+ public function shouldGetLatestRelease ()
13+ {
14+ $ expectedValue = array ('latest_release_data ' );
15+
16+ $ api = $ this ->getApiMock ();
17+ $ api ->expects ($ this ->once ())
18+ ->method ('get ' )
19+ ->with ('repos/KnpLabs/php-github-api/releases/latest ' )
20+ ->will ($ this ->returnValue ($ expectedValue ));
21+
22+ $ this ->assertEquals ($ expectedValue , $ api ->latest ('KnpLabs ' , 'php-github-api ' ));
23+ }
24+
25+ /**
26+ * @test
27+ */
28+ public function shouldGetReleaseByTag ()
29+ {
30+ $ expectedValue = array ('latest_release_data ' );
31+
32+ $ api = $ this ->getApiMock ();
33+ $ api ->expects ($ this ->once ())
34+ ->method ('get ' )
35+ ->with ('repos/KnpLabs/php-github-api/releases/tags/5f078080e01e0365690920d618f12342d2c941c8 ' )
36+ ->will ($ this ->returnValue ($ expectedValue ));
37+
38+ $ this ->assertEquals ($ expectedValue , $ api ->tag (
39+ 'KnpLabs ' ,
40+ 'php-github-api ' ,
41+ '5f078080e01e0365690920d618f12342d2c941c8 '
42+ ));
43+ }
44+
945 /**
1046 * @test
1147 */
You can’t perform that action at this time.
0 commit comments