@@ -19,12 +19,13 @@ public function testCallsCorrectURL()
19
19
//arrange
20
20
$ http_client = Mockery::mock (ClientInterface::class, [
21
21
'request ' => Mockery::mock (ResponseInterface::class, [
22
+ 'getStatusCode ' => 200 ,
22
23
'getBody ' => Mockery::mock (StreamInterface::class, [
23
24
'getContents ' => json_encode (['test_field ' => 'test value ' ])
24
25
])
25
26
])
26
27
]);
27
- $ api = new PackagistAPI ($ http_client );
28
+ $ api = new PackagistAPI ($ http_client, STDERR );
28
29
29
30
//act
30
31
$ package_info = $ api ->getPackageInfo ('vendor_name/package_name ' );
@@ -38,12 +39,13 @@ public function testCanGetPackageInfo()
38
39
//arrange
39
40
$ http_client = Mockery::mock (ClientInterface::class, [
40
41
'request ' => Mockery::mock (ResponseInterface::class, [
41
- 'getBody ' => Mockery::mock (StreamInterface::class, [
42
+ 'getStatusCode ' => 200 ,
43
+ 'getBody ' => Mockery::mock (StreamInterface::class, [
42
44
'getContents ' => json_encode (['test_field ' => 'test value ' ])
43
45
])
44
46
])
45
47
]);
46
- $ api = new PackagistAPI ($ http_client );
48
+ $ api = new PackagistAPI ($ http_client, STDERR );
47
49
48
50
//act
49
51
$ package_info = $ api ->getPackageInfo ('vendor_name/package_name ' );
@@ -52,22 +54,23 @@ public function testCanGetPackageInfo()
52
54
$ this ->assertEquals ('test value ' , $ package_info ['test_field ' ]);
53
55
}
54
56
55
- public function testCanHandleBadResponse ()
56
- {
57
- //arrange
58
- $ http_client = Mockery::mock (ClientInterface::class, [
59
- 'request ' => Mockery::mock (ResponseInterface::class, [
60
- 'getBody ' => Mockery::mock (StreamInterface::class, [
61
- 'getContents ' => '<html>This is not valid JSON</html> '
62
- ])
63
- ])
64
- ]);
65
- $ api = new PackagistAPI ($ http_client );
57
+ public function testCanHandleBadResponse ()
58
+ {
59
+ //arrange
60
+ $ http_client = Mockery::mock (ClientInterface::class, [
61
+ 'request ' => Mockery::mock (ResponseInterface::class, [
62
+ 'getStatusCode ' => 200 ,
63
+ 'getBody ' => Mockery::mock (StreamInterface::class, [
64
+ 'getContents ' => '<html>This is not valid JSON</html> '
65
+ ])
66
+ ])
67
+ ]);
68
+ $ api = new PackagistAPI ($ http_client , STDERR );
66
69
67
- //act
68
- $ package_info = $ api ->getPackageInfo ('vendor_name/package_name ' );
70
+ //act
71
+ $ package_info = $ api ->getPackageInfo ('vendor_name/package_name ' );
69
72
70
- //assert
71
- $ this ->assertEquals ([], $ package_info );
72
- }
73
+ //assert
74
+ $ this ->assertEquals ([], $ package_info );
75
+ }
73
76
}
0 commit comments