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 3
3
4
4
This Github API Endpoint is currently undocumented because it's new, but works just fine.
5
5
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
+ ```
6
17
7
18
### List all releases
8
19
Original file line number Diff line number Diff line change 12
12
*/
13
13
class Releases extends AbstractApi
14
14
{
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
+
15
42
/**
16
43
* List releases in selected repository.
17
44
*
Original file line number Diff line number Diff line change 6
6
7
7
class ReleasesTest extends TestCase
8
8
{
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
+
9
45
/**
10
46
* @test
11
47
*/
You can’t perform that action at this time.
0 commit comments