File tree Expand file tree Collapse file tree 10 files changed +204
-1
lines changed
test/Github/Tests/Api/Miscellaneous Expand file tree Collapse file tree 10 files changed +204
-1
lines changed Original file line number Diff line number Diff line change 1414* [ Issues] ( issues.md )
1515 * [ Comments] ( issue/comments.md )
1616 * [ Labels] ( issue/labels.md )
17+ * Miscellaneous
18+ * [ Emojis] ( miscellaneous/emojis.md )
19+ * [ Gitignore] ( miscellaneous/gitignore.md )
20+ * [ Markdown] ( miscellaneous/markdown.md )
1721* [ Organization] ( organization.md )
1822 * [ Members] ( organization/members.md )
1923 * [ Teams] ( organization/teams.md )
Original file line number Diff line number Diff line change 1+ ## Emojis API
2+ [ Back to the navigation] ( ../README.md )
3+
4+ ### Lists all available emojis on GitHub.
5+
6+ ``` php
7+ $emojis = $client->api('emojis')->all();
8+ ```
Original file line number Diff line number Diff line change 1+ ## Gitignore API
2+ [ Back to the navigation] ( ../README.md )
3+
4+ ### Lists all available gitignore templates
5+
6+ ``` php
7+ $gitignoreTemplates = $client->api('gitignore')->all();
8+ ```
9+
10+ ### Get a single template
11+
12+ ``` php
13+ $gitignore = $client->api('gitignore')->show('C');
14+ ```
Original file line number Diff line number Diff line change 1+ ## Markdown API
2+ [ Back to the navigation] ( ../README.md )
3+
4+ ### Render an arbitrary Markdown document
5+
6+ ``` php
7+ $gitignoreTemplates = $client->api('markdown')->render('Hello world github/linguist#1 **cool**, and #1!', 'markdown');
8+ ```
9+
10+ ### Render a Markdown document in raw mode
11+
12+ ``` php
13+ $gitignore = $client->api('markdown')->renderRaw('path/to/file');
14+ ```
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Github \Api \Miscellaneous ;
4+
5+ use Github \Api \AbstractApi ;
6+
7+ class Emojis extends AbstractApi
8+ {
9+ /**
10+ * Lists all the emojis available to use on GitHub.
11+ *
12+ * @link https://developer.github.com/v3/emojis/
13+ *
14+ * @return array
15+ */
16+ public function all ()
17+ {
18+ return $ this ->get ('/emojis ' );
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Github \Api \Miscellaneous ;
4+
5+ use Github \Api \AbstractApi ;
6+
7+ class Gitignore extends AbstractApi
8+ {
9+ /**
10+ * List all templates available to pass as an option when creating a repository.
11+ *
12+ * @link https://developer.github.com/v3/gitignore/#listing-available-templates
13+ *
14+ * @return array
15+ */
16+ public function all ()
17+ {
18+ return $ this ->get ('/gitignore/templates ' );
19+ }
20+
21+ /**
22+ * Get a single template.
23+ *
24+ * @link https://developer.github.com/v3/gitignore/#get-a-single-template
25+ *
26+ * @param string $template
27+ *
28+ * @return array
29+ */
30+ public function show ($ template )
31+ {
32+ return $ this ->get ('/gitignore/templates/ ' . rawurlencode ($ template ));
33+ }
34+ }
Original file line number Diff line number Diff line change 2323 * @method Api\CurrentUser me()
2424 * @method Api\Enterprise ent()
2525 * @method Api\Enterprise enterprise()
26+ * @method Api\Miscellaneous\Emojis emojis()
2627 * @method Api\GitData git()
2728 * @method Api\GitData gitData()
2829 * @method Api\Gists gist()
2930 * @method Api\Gists gists()
31+ * @method Api\Miscellaneous\Gitignore gitignore()
3032 * @method Api\Integrations integration()
3133 * @method Api\Integrations integrations()
3234 * @method Api\Issue issue()
@@ -177,6 +179,10 @@ public function api($name)
177179 $ api = new Api \Enterprise ($ this );
178180 break ;
179181
182+ case 'emojis ' :
183+ $ api = new Api \Miscellaneous \Emojis ($ this );
184+ break ;
185+
180186 case 'git ' :
181187 case 'git_data ' :
182188 case 'gitData ' :
@@ -188,6 +194,10 @@ public function api($name)
188194 $ api = new Api \Gists ($ this );
189195 break ;
190196
197+ case 'gitignore ' :
198+ $ api = new Api \Miscellaneous \Gitignore ($ this );
199+ break ;
200+
191201 case 'integration ' :
192202 case 'integrations ' :
193203 $ api = new Api \Integrations ($ this );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Github \Tests \Api \Miscellaneous ;
4+
5+ use Github \Api \Miscellaneous \Emojis ;
6+ use Github \Tests \Api \TestCase ;
7+
8+ class EmojisTest extends TestCase
9+ {
10+ /**
11+ * @test
12+ */
13+ public function shouldGetAllEmojis ()
14+ {
15+ $ expectedArray = array (
16+ '+1 ' => 'https://github.global.ssl.fastly.net/images/icons/emoji/+1.png?v5 ' ,
17+ '-1 ' => 'https://github.global.ssl.fastly.net/images/icons/emoji/-1.png?v5 ' ,
18+ );
19+
20+ $ api = $ this ->getApiMock ();
21+ $ api ->expects ($ this ->once ())
22+ ->method ('get ' )
23+ ->with ('/emojis ' )
24+ ->will ($ this ->returnValue ($ expectedArray ));
25+
26+ $ this ->assertEquals ($ expectedArray , $ api ->all ());
27+ }
28+
29+ /**
30+ * @return string
31+ */
32+ protected function getApiClass ()
33+ {
34+ return Emojis::class;
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Github \Tests \Api \Miscellaneous ;
4+
5+ use Github \Api \Miscellaneous \Emojis ;
6+ use Github \Api \Miscellaneous \Gitignore ;
7+ use Github \Tests \Api \TestCase ;
8+
9+ class GitignoreTest extends TestCase
10+ {
11+ /**
12+ * @test
13+ */
14+ public function shouldGetAllTemplates ()
15+ {
16+ $ expectedArray = array (
17+ 'Actionscript ' ,
18+ 'Android ' ,
19+ 'AppceleratorTitanium ' ,
20+ 'Autotools ' ,
21+ 'Bancha ' ,
22+ 'C ' ,
23+ 'C++ '
24+ );
25+
26+ $ api = $ this ->getApiMock ();
27+ $ api ->expects ($ this ->once ())
28+ ->method ('get ' )
29+ ->with ('/gitignore/templates ' )
30+ ->will ($ this ->returnValue ($ expectedArray ));
31+
32+ $ this ->assertEquals ($ expectedArray , $ api ->all ());
33+ }
34+
35+ /**
36+ * @test
37+ */
38+ public function shouldGetTemplate ()
39+ {
40+ $ expectedArray = array (
41+ 'name ' => 'C ' ,
42+ 'source ' => "# Object files \n*.o \n\n# Libraries \n*.lib \n*.a "
43+ );
44+
45+ $ api = $ this ->getApiMock ();
46+ $ api ->expects ($ this ->once ())
47+ ->method ('get ' )
48+ ->with ('/gitignore/templates/C ' )
49+ ->will ($ this ->returnValue ($ expectedArray ));
50+
51+ $ this ->assertEquals ($ expectedArray , $ api ->show ('C ' ));
52+ }
53+
54+ /**
55+ * @return string
56+ */
57+ protected function getApiClass ()
58+ {
59+ return Gitignore::class;
60+ }
61+ }
Original file line number Diff line number Diff line change 11<?php
22
3- namespace Github \Tests \Api ;
3+ namespace Github \Tests \Api \Miscellaneous ;
4+
5+ use Github \Tests \Api \TestCase ;
46
57class MarkdownTest extends TestCase
68{
You can’t perform that action at this time.
0 commit comments