@@ -32,21 +32,26 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
32
32
/**
33
33
* @dataProvider provideJson
34
34
*/
35
- public function testFromJson ($ json , $ success , $ errorCodes )
35
+ public function testFromJson ($ json , $ success , $ errorCodes, $ hostname )
36
36
{
37
37
$ response = Response::fromJson ($ json );
38
38
$ this ->assertEquals ($ success , $ response ->isSuccess ());
39
39
$ this ->assertEquals ($ errorCodes , $ response ->getErrorCodes ());
40
+ $ this ->assertEquals ($ hostname , $ response ->getHostname ());
40
41
}
41
42
42
43
public function provideJson ()
43
44
{
44
45
return array (
45
- array ('{"success": true} ' , true , array ()),
46
- array ('{"success": false, "error-codes": ["test"]} ' , false , array ('test ' )),
47
- array ('{"success": true, "error-codes": ["test"]} ' , true , array ()),
48
- array ('{"success": false} ' , false , array ()),
49
- array ('BAD JSON ' , false , array ('invalid-json ' )),
46
+ array ('{"success": true} ' , true , array (), null ),
47
+ array ('{"success": true, "hostname": "google.com"} ' , true , array (), 'google.com ' ),
48
+ array ('{"success": false, "error-codes": ["test"]} ' , false , array ('test ' ), null ),
49
+ array ('{"success": false, "error-codes": ["test"], "hostname": "google.com"} ' , false , array ('test ' ), 'google.com ' ),
50
+ array ('{"success": true, "error-codes": ["test"]} ' , true , array (), null ),
51
+ array ('{"success": true, "error-codes": ["test"], "hostname": "google.com"} ' , true , array (), 'google.com ' ),
52
+ array ('{"success": false} ' , false , array (), null ),
53
+ array ('{"success": false, "hostname": "google.com"} ' , false , array (), 'google.com ' ),
54
+ array ('BAD JSON ' , false , array ('invalid-json ' ), null ),
50
55
);
51
56
}
52
57
@@ -68,4 +73,12 @@ public function testGetErrorCodes()
68
73
$ response = new Response (true , $ errorCodes );
69
74
$ this ->assertEquals ($ errorCodes , $ response ->getErrorCodes ());
70
75
}
76
+
77
+ public function testGetHostname ()
78
+ {
79
+ $ hostname = 'google.com ' ;
80
+ $ errorCodes = array ();
81
+ $ response = new Response (true , $ errorCodes , $ hostname );
82
+ $ this ->assertEquals ($ hostname , $ response ->getHostname ());
83
+ }
71
84
}
0 commit comments