@@ -9,7 +9,6 @@ require __DIR__ . '/../bootstrap.php';
99
1010class MockIClient implements Milo \Github \Http \IClient
1111{
12- /** @return Milo\Github\Http\Response */
1312 public function request (Milo \Github \Http \Request $ request )
1413 {
1514 throw new \LogicException ;
@@ -19,20 +18,11 @@ class MockIClient implements Milo\Github\Http\IClient
1918 public function onResponse ($ cb ) {}
2019}
2120
22- class TestApi extends Milo \Github \Api
23- {
24- public function substituteUrlParameters (& $ url , array & $ parameters )
25- {
26- return parent ::substituteUrlParameters ($ url , $ parameters );
27- }
28- }
29-
30-
3121
3222# Basics
3323test (function () {
3424 $ client = new MockIClient ;
35- $ api = new TestApi ($ client );
25+ $ api = new Milo \ Github \ Api ($ client );
3626
3727 Assert::same ($ client , $ api ->getClient ());
3828 Assert::same ('https://api.github.com ' , $ api ->getUrl ());
@@ -48,47 +38,10 @@ test(function() {
4838});
4939
5040
51- # substituteUrl()
52- test (function () {
53- $ client = new MockIClient ;
54- $ api = new TestApi ($ client );
55-
56- $ urls = [
57- '' => ['' , ['a ' => 'A ' , 'b ' => 'B ' ]],
58- '/ ' => ['/ ' , ['a ' => 'A ' , 'b ' => 'B ' ]],
59- ':a ' => ['A ' , ['b ' => 'B ' ]],
60- '/:a ' => ['/A ' , ['b ' => 'B ' ]],
61- ':a/ ' => ['A/ ' , ['b ' => 'B ' ]],
62- '/:a/ ' => ['/A/ ' , ['b ' => 'B ' ]],
63- '/:a/:b/c ' => ['/A/B/c ' , []],
64- ];
65-
66- foreach ($ urls as $ url => $ result ) {
67- $ params = ['a ' => 'A ' , 'b ' => 'B ' ];
68- $ api ->substituteUrlParameters ($ url , $ params );
69-
70- Assert::same ($ url , $ result [0 ]);
71- Assert::same ($ params , $ result [1 ]);
72- }
73-
74- Assert::exception (function () use ($ api ) {
75- $ url = ':a ' ;
76- $ params = ['A ' => 'a ' ];
77- $ api ->substituteUrlParameters ($ url , $ params );
78- }, 'Milo\Github\MissingParameterException ' , "Missing parameter 'a' for URL path ':a'. " );
79-
80- Assert::exception (function () use ($ api ) {
81- $ url = ':a:b ' ;
82- $ params = ['a ' => 'A ' , 'b ' => 'B ' ];
83- $ api ->substituteUrlParameters ($ url , $ params );
84- }, 'Milo\Github\MissingParameterException ' , "Missing parameter 'a:b' for URL path ':a:b'. " );
85- });
86-
87-
8841# createRequest()
8942test (function () {
9043 $ client = new MockIClient ;
91- $ api = new TestApi ($ client );
44+ $ api = new Milo \ Github \ Api ($ client );
9245
9346 # All slashes in URL
9447 $ api ->setUrl ('url://test/ ' );
@@ -117,7 +70,7 @@ test(function() {
11770# Default parameters
11871test (function () {
11972 $ client = new MockIClient ;
120- $ api = new TestApi ($ client );
73+ $ api = new Milo \ Github \ Api ($ client );
12174 $ api ->setUrl ('url://test ' );
12275
12376 Assert::same ([], $ api ->getDefaultParameters ());
@@ -140,7 +93,7 @@ test(function() {
14093# Paginator
14194test (function () {
14295 $ client = new MockIClient ;
143- $ api = new TestApi ($ client );
96+ $ api = new Milo \ Github \ Api ($ client );
14497
14598 Assert::type ('Milo\Github\Paginator ' , $ api ->paginator ('' ));
14699});
0 commit comments