@@ -13,38 +13,46 @@ class ClientTest extends TestCase
13
13
public function setUp ()
14
14
{
15
15
$ this ->browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
16
+ $ this ->browser ->expects ($ this ->any ())->method ('withBase ' )->willReturn ($ this ->browser );
16
17
17
18
$ this ->client = new Client ($ this ->browser );
18
19
}
19
20
20
21
public function testGet ()
21
22
{
22
- $ this ->setupBrowser ('packages/clue/zenity -react.json ' , $ this ->createResponsePromise ('{"package":{"name":"clue\/zenity-react", "versions": {}}} ' ));
23
+ $ this ->setupBrowser ('/ packages/clue%2Fzenity -react.json ' , $ this ->createResponsePromise ('{"package":{"name":"clue\/zenity-react", "versions": {}}} ' ));
23
24
24
25
$ this ->expectPromiseResolve ($ this ->client ->get ('clue/zenity-react ' ));
25
26
}
26
27
27
28
public function testAll ()
28
29
{
29
- $ this ->setupBrowser ('packages/list.json ' , $ this ->createResponsePromise ('{"packageNames":["a/a", "b/b"]} ' ));
30
+ $ this ->setupBrowser ('/ packages/list.json ' , $ this ->createResponsePromise ('{"packageNames":["a/a", "b/b"]} ' ));
30
31
31
32
$ this ->expectPromiseResolve ($ this ->client ->all ());
32
33
}
33
34
34
35
public function testAllVendor ()
35
36
{
36
- $ this ->setupBrowser ('packages/list.json?vendor=a ' , $ this ->createResponsePromise ('{"packageNames":["a/a"]} ' ));
37
+ $ this ->setupBrowser ('/ packages/list.json?vendor=a ' , $ this ->createResponsePromise ('{"packageNames":["a/a"]} ' ));
37
38
38
39
$ this ->expectPromiseResolve ($ this ->client ->all (array ('vendor ' => 'a ' )));
39
40
}
40
41
41
42
public function testSearch ()
42
43
{
43
- $ this ->setupBrowser ('search.json?q=zenity ' , $ this ->createResponsePromise ('{"results":[{"name":"clue\/zenity-react","description":"Build graphical desktop (GUI) applications in PHP","url":"https:\/\/packagist.org\/packages\/clue\/zenity-react","downloads":57,"favers":0,"repository":"https:\/\/github.com\/clue\/reactphp-zenity"}],"total":1} ' ));
44
+ $ this ->setupBrowser ('/ search.json?q=zenity ' , $ this<
F024
/span> ->createResponsePromise ('{"results":[{"name":"clue\/zenity-react","description":"Build graphical desktop (GUI) applications in PHP","url":"https:\/\/packagist.org\/packages\/clue\/zenity-react","downloads":57,"favers":0,"repository":"https:\/\/github.com\/clue\/reactphp-zenity"}],"total":1} ' ));
44
45
45
46
$ this ->expectPromiseResolve ($ this ->client ->search ('zenity ' ));
46
47
}
47
48
49
+ public function testSearchSpecialWithNoResults ()
50
+ {
51
+ $ this ->setupBrowser ('/search.json?q=%3C%C3%A4%3E ' , $ this ->createResponsePromise ('{"results":[],"total":0} ' ));
52
+
53
+ $ this ->expectPromiseResolve ($ this ->client ->search ('<ä> ' ));
54
+ }
55
+
48
56
public function testSearchPagination ()
49
57
{
50
58
$ this ->browser ->expects ($ this ->exactly (2 ))
@@ -59,7 +67,7 @@ public function testSearchPagination()
59
67
60
68
public function testHttpError ()
61
69
{
62
- $ this ->setupBrowser ('packages/clue/invalid .json ' , $ this ->createRejectedPromise (new RuntimeException ('error ' )));
70
+ $ this ->setupBrowser ('/ packages/clue%2Finvalid .json ' , $ this ->createRejectedPromise (new RuntimeException ('error ' )));
63
71
64
72
$ this ->expectPromiseReject ($ this ->client ->get ('clue/invalid ' ));
65
73
}
@@ -68,7 +76,7 @@ private function setupBrowser($expectedUrl, $promise)
68
76
{
69
77
$ this ->browser ->expects ($ this ->once ())
70
78
->method ('get ' )
71
- ->with ($ this ->equalTo (' https://packagist.org/ ' . $ expectedUrl ), array ())
79
+ ->with ($ this ->equalTo ($ expectedUrl ), array ())
72
80
->will ($ this ->returnValue ($ promise ));
73
81
}
74
82
0 commit comments