| @@ 26-38 (lines=13) @@ | ||
| 23 | class YahooWeatherClientTests extends TestCase |
|
| 24 | { |
|
| 25 | /** @test */ |
|
| 26 | public function testCallApiWoeidException() |
|
| 27 | { |
|
| 28 | $service = new YahooWeatherAPI(); |
|
| 29 | ||
| 30 | $this->expectException(\Exception::class); |
|
| 31 | ||
| 32 | try { |
|
| 33 | $response = $service->callApiWoeid(null); |
|
| 34 | } catch (\Exception $e) { |
|
| 35 | throw $e; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| 39 | /** @test */ |
|
| 40 | public function testCallApiCityNameException() |
|
| 41 | { |
|
| @@ 40-52 (lines=13) @@ | ||
| 37 | } |
|
| 38 | ||
| 39 | /** @test */ |
|
| 40 | public function testCallApiCityNameException() |
|
| 41 | { |
|
| 42 | $service = new YahooWeatherAPI(); |
|
| 43 | ||
| 44 | $this->expectException(\Exception::class); |
|
| 45 | ||
| 46 | try { |
|
| 47 | $response = $service->callApiCityName(null); |
|
| 48 | } catch (\Exception $e) { |
|
| 49 | throw $e; |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** @test */ |
|
| 54 | public function testCallApiTestException() |
|
| 55 | { |
|
| @@ 54-66 (lines=13) @@ | ||
| 51 | } |
|
| 52 | ||
| 53 | /** @test */ |
|
| 54 | public function testCallApiTestException() |
|
| 55 | { |
|
| 56 | $service = new YahooWeatherAPI(); |
|
| 57 | ||
| 58 | $this->expectException(\Exception::class); |
|
| 59 | ||
| 60 | try { |
|
| 61 | $response = $service->callApi(null); |
|
| 62 | } catch (\Exception $e) { |
|
| 63 | throw $e; |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| 67 | /** @test */ |
|
| 68 | public function testCallApiLastRes() |
|
| 69 | { |
|
| @@ 68-82 (lines=15) @@ | ||
| 65 | } |
|
| 66 | ||
| 67 | /** @test */ |
|
| 68 | public function testCallApiLastRes() |
|
| 69 | { |
|
| 70 | $errYql = 'https://query.yahooapis.com/v1/public/yql?q=from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text=%22Taipei%22)&format=json&env=store://datatables.org/alltableswithkeys'; |
|
| 71 | ||
| 72 | $service = new YahooWeatherAPI(); |
|
| 73 | ||
| 74 | $this->expectException(\Exception::class); |
|
| 75 | ||
| 76 | try { |
|
| 77 | $response = $service->callApi($errYql); |
|
| 78 | } catch (\Exception $e) { |
|
| 79 | throw $e; |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||
| 83 | /** @test */ |
|
| 84 | public function setClientTest() |
|
| 85 | { |
|