77
88class ClientTest extends TestCase
99{
10- private $ url ;
1110 private $ browser ;
1211 private $ client ;
1312
1413 public function setUp ()
1514 {
16- $ this -> url = ' http://viewvc.example.org ' ;
17- $ this ->browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
18- $ this ->client = new Client ($ this ->url , $ this -> browser );
15+ // test case does not take base URI into account
16+ $ this ->browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->setMethods ( array ( ' get ' ))-> getMock ();
17+ $ this ->client = new Client ($ this ->browser );
1918 }
2019
2120 public function testInvalidDirectory ()
@@ -33,7 +32,7 @@ public function testInvalidFile()
3332 public function testFetchFile ()
3433 {
3534 $ response = new Response ('HTTP/1.0 ' , 200 , 'OK ' , array (), new Body ('# hello ' ));
36- $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('http://viewvc.example.org/ README.md?view=co ' ))->will ($ this ->returnValue (Promise \resolve ($ response )));
35+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('README.md?view=co ' ))->will ($ this ->returnValue (Promise \resolve ($ response )));
3736
3837 $ promise = $ this ->client ->fetchFile ('README.md ' );
3938
@@ -42,17 +41,16 @@ public function testFetchFile()
4241
4342 public function testFetchFileExcessiveSlashesAreIgnored ()
4443 {
45- $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('http://viewvc.example.org/ README.md?view=co ' ))->will ($ this ->returnValue (Promise \reject ()));
44+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('README.md?view=co ' ))->will ($ this ->returnValue (Promise \reject ()));
4645
47- $ client = new Client ($ this ->url . '/ ' , $ this ->browser );
48- $ promise = $ client ->fetchFile ('/README.md ' );
46+ $ promise = $ this ->client ->fetchFile ('/README.md ' );
4947
5048 $ this ->expectPromiseReject ($ promise );
5149 }
5250
5351 public function testFetchFileRevision ()
5452 {
55- $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('http://viewvc.example.org/ README.md?view=co&pathrev=1.0 ' ))->will ($ this ->returnValue (Promise \reject ()));
53+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('README.md?view=co&pathrev=1.0 ' ))->will ($ this ->returnValue (Promise \reject ()));
5654
5755 $ promise = $ this ->client ->fetchFile ('/README.md ' , '1.0 ' );
5856
@@ -61,7 +59,7 @@ public function testFetchFileRevision()
6159
6260 public function testFetchDirectoryRevision ()
6361 {
64- $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('http://viewvc.example.org/ directory/?pathrev=1.0 ' ))->will ($ this ->returnValue (Promise \reject ()));
62+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('directory/?pathrev=1.0 ' ))->will ($ this ->returnValue (Promise \reject ()));
6563
6664 $ promise = $ this ->client ->fetchDirectory ('/directory/ ' , '1.0 ' );
6765
@@ -70,7 +68,7 @@ public function testFetchDirectoryRevision()
7068
7169 public function testFetchDirectoryAttic ()
7270 {
73- $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('http://viewvc.example.org/ directory/?hideattic=0 ' ))->will ($ this ->returnValue (Promise \reject ()));
71+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('directory/?hideattic=0 ' ))->will ($ this ->returnValue (Promise \reject ()));
7472
7573 $ promise = $ this ->client ->fetchDirectory ('/directory/ ' , null , true );
7674
@@ -79,7 +77,7 @@ public function testFetchDirectoryAttic()
7977
8078 public function testFetchDirectoryRevisionAttic ()
8179 {
82- $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('http://viewvc.example.org/ directory/?pathrev=1.1&hideattic=0 ' ))->will ($ this ->returnValue (Promise \reject ()));
80+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('directory/?pathrev=1.1&hideattic=0 ' ))->will ($ this ->returnValue (Promise \reject ()));
8381
8482 $ promise = $ this ->client ->fetchDirectory ('/directory/ ' , '1.1 ' , true );
8583
@@ -88,7 +86,7 @@ public function testFetchDirectoryRevisionAttic()
8886
8987 public function testFetchLogRevision ()
9088 {
91- $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('http://viewvc.example.org/ README.md?view=log&pathrev=1.0 ' ))->will ($ this ->returnValue (Promise \reject ()));
89+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('README.md?view=log&pathrev=1.0 ' ))->will ($ this ->returnValue (Promise \reject ()));
9290
9391 $ promise = $ this ->client ->fetchLog ('/README.md ' , '1.0 ' );
9492
@@ -97,7 +95,7 @@ public function testFetchLogRevision()
9795
9896 public function testFetchPatch ()
9997 {
100- $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('http://viewvc.example.org/ README.md?view=patch&r1=1.0&r2=1.1 ' ))->will ($ this ->returnValue (Promise \reject ()));
98+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('README.md?view=patch&r1=1.0&r2=1.1 ' ))->will ($ this ->returnValue (Promise \reject ()));
10199
102100 $ promise = $ this ->client ->fetchPatch ('/README.md ' , '1.0 ' , '1.1 ' );
103101
0 commit comments