7
7
8
8
class ClientTest extends TestCase
9
9
{
10
- private $ url ;
11
10
private $ browser ;
12
11
private $ client ;
13
12
14
13
public function setUp ()
15
14
{
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 );
19
18
}
20
19
21
20
public function testInvalidDirectory ()
@@ -33,7 +32,7 @@ public function testInvalidFile()
33
32
public function testFetchFile ()
34
33
{
35
34
$ 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 )));
37
36
38
37
$ promise = $ this ->client ->fetchFile ('README.md ' );
39
38
@@ -42,17 +41,16 @@ public function testFetchFile()
42
41
43
42
public function testFetchFileExcessiveSlashesAreIgnored ()
44
43
{
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 ()));
46
45
47
- $ client = new Client ($ this ->url . '/ ' , $ this ->browser );
48
- $ promise = $ client ->fetchFile ('/README.md ' );
46
+ $ promise = $ this ->client ->fetchFile ('/README.md ' );
49
47
50
48
$ this ->expectPromiseReject ($ promise );
51
49
}
52
50
53
51
public function testFetchFileRevision ()
54
52
{
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 ()));
56
54
57
55
$ promise = $ this ->client ->fetchFile ('/README.md ' , '1.0 ' );
58
56
@@ -61,7 +59,7 @@ public function testFetchFileRevision()
61
59
62
60
public function testFetchDirectoryRevision ()
63
61
{
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 ()));
65
63
66
64
$ promise = $ this ->client ->fetchDirectory ('/directory/ ' , '1.0 ' );
67
65
@@ -70,7 +68,7 @@ public function testFetchDirectoryRevision()
70
68
71
69
public function testFetchDirectoryAttic ()
72
70
{
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 ()));
74
72
75
73
$ promise = $ this ->client ->fetchDirectory ('/directory/ ' , null , true );
76
74
@@ -79,7 +77,7 @@ public function testFetchDirectoryAttic()
79
77
80
78
public function testFetchDirectoryRevisionAttic ()
81
79
{
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 ()));
83
81
84
82
$ promise = $ this ->client ->fetchDirectory ('/directory/ ' , '1.1 ' , true );
85
83
@@ -88,7 +86,7 @@ public function testFetchDirectoryRevisionAttic()
88
86
89
87
public function testFetchLogRevision ()
90
88
{
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 ()));
92
90
93
91
$ promise = $ this ->client ->fetchLog ('/README.md ' , '1.0 ' );
94
92
@@ -97,7 +95,7 @@ public function testFetchLogRevision()
97
95
98
96
public function testFetchPatch ()
99
97
{
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 ()));
101
99
102
100
$ promise = $ this ->client ->fetchPatch ('/README.md ' , '1.0 ' , '1.1 ' );
103
101
0 commit comments