@@ 59-74 (lines=16) @@ | ||
56 | $this->assertSame('127.0.0.1', $geoIp->getIpAddress()); |
|
57 | } |
|
58 | ||
59 | public function testRequestInvalid() |
|
60 | { |
|
61 | $stub = $this->getMockBuilder('ipGeolocation\GeoIPLocation') |
|
62 | ->setMethods(array('getRequestUrl')) |
|
63 | ->getMock(); |
|
64 | ||
65 | $stub->method('getRequestUrl') |
|
66 | ->with() |
|
67 | ->willReturn('http://httpbin.org/status/undefined'); |
|
68 | ||
69 | ||
70 | $location = $stub->getGeoLocation(); |
|
71 | ||
72 | $this->assertFalse($location->getStatus()); |
|
73 | $this->assertSame('Client error: 400', $location->getMessage()); |
|
74 | } |
|
75 | ||
76 | public function testResponseInvalid() |
|
77 | { |
|
@@ 76-90 (lines=15) @@ | ||
73 | $this->assertSame('Client error: 400', $location->getMessage()); |
|
74 | } |
|
75 | ||
76 | public function testResponseInvalid() |
|
77 | { |
|
78 | $stub = $this->getMockBuilder('ipGeolocation\GeoIPLocation') |
|
79 | ->setMethods(array('getRequestUrl')) |
|
80 | ->getMock(); |
|
81 | ||
82 | $stub->method('getRequestUrl') |
|
83 | ->with() |
|
84 | ->willReturn('http://httpbin.org/status/300'); |
|
85 | ||
86 | $location = $stub->getGeoLocation(); |
|
87 | ||
88 | $this->assertFalse($location->getStatus()); |
|
89 | $this->assertSame('Request failed with response code: 300 and response: Multiple Choices', $location->getMessage()); |
|
90 | } |
|
91 | } |
|
92 |