File tree 10 files changed +204
-1
lines changed
test/Github/Tests/Api/Miscellaneous
10 files changed +204
-1
lines changed Original file line number Diff line number Diff line change 14
14
* [ Issues] ( issues.md )
15
15
* [ Comments] ( issue/comments.md )
16
16
* [ Labels] ( issue/labels.md )
17
+ * Miscellaneous
18
+ * [ Emojis] ( miscellaneous/emojis.md )
19
+ * [ Gitignore] ( miscellaneous/gitignore.md )
20
+ * [ Markdown] ( miscellaneous/markdown.md )
17
21
* [ Organization] ( organization.md )
18
22
* [ Members] ( organization/members.md )
19
23
* [ 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 23
23
* @method Api\CurrentUser me()
24
24
* @method Api\Enterprise ent()
25
25
* @method Api\Enterprise enterprise()
26
+ * @method Api\Miscellaneous\Emojis emojis()
26
27
* @method Api\GitData git()
27
28
* @method Api\GitData gitData()
28
29
* @method Api\Gists gist()
29
30
* @method Api\Gists gists()
31
+ * @method Api\Miscellaneous\Gitignore gitignore()
30
32
* @method Api\Integrations integration()
31
33
* @method Api\Integrations integrations()
32
34
* @method Api\Issue issue()
@@ -177,6 +179,10 @@ public function api($name)
177
179
$ api = new Api \Enterprise ($ this );
178
180
break ;
179
181
182
+ case 'emojis ' :
183
+ $ api = new Api \Miscellaneous \Emojis ($ this );
184
+ break ;
185
+
180
186
case 'git ' :
181
187
case 'git_data ' :
182
188
case 'gitData ' :
@@ -188,6 +194,10 @@ public function api($name)
188
194
$ api = new Api \Gists ($ this );
189
195
break ;
190
196
197
+ case 'gitignore ' :
198
+ $ api = new Api \Miscellaneous \Gitignore ($ this );
199
+ break ;
200
+
191
201
case 'integration ' :
192
202
case 'integrations ' :
193
203
$ 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 1
1
<?php
2
2
3
- namespace Github \Tests \Api ;
3
+ namespace Github \Tests \Api \Miscellaneous ;
4
+
5
+ use Github \Tests \Api \TestCase ;
4
6
5
7
class MarkdownTest extends TestCase
6
8
{
You can’t perform that action at this time.
0 commit comments