@@ 70-105 (lines=36) @@ | ||
67 | $this->assertTrue($result); |
|
68 | } |
|
69 | ||
70 | public function testJsonHasCountryAndPopulation() |
|
71 | { |
|
72 | $fakeJson = '{ |
|
73 | "cod":"200","calctime":"123456789","message":0.0032,"city_id":{"id":1851632,"name":"Shuzenji","coord":{"lon":138.933334,"lat":34.966671},"country":"JP"}, |
|
74 | "cnt":10, |
|
75 | "list":[{ |
|
76 | "city":{ |
|
77 | "country": "Berlin", |
|
78 | "population": "10,000" |
|
79 | } |
|
80 | },{ |
|
81 | "dt":1406080800, |
|
82 | "temp":{ |
|
83 | "day":297.77, |
|
84 | "min":293.52, |
|
85 | "max":297.77, |
|
86 | "night":293.52, |
|
87 | "eve":297.77, |
|
88 | "morn":297.77 |
|
89 | }, |
|
90 | "pressure":925.04, |
|
91 | "humidity":76, |
|
92 | "weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}], |
|
93 | "main":{"temp":306.15,"pressure":1013,"humidity":44,"temp_min":306,"temp_max":306}, |
|
94 | "clouds":{"all":90}, |
|
95 | "wind":{"speed":5.71,"deg":229.501} |
|
96 | }] |
|
97 | }'; |
|
98 | $fakeJson = json_decode($fakeJson, true); |
|
99 | $history = new WeatherHistory($fakeJson, 'Berlin'); |
|
100 | ||
101 | $history->rewind(); |
|
102 | $result = $history->valid(); |
|
103 | ||
104 | $this->assertTrue($result); |
|
105 | } |
|
106 | ||
107 | public function testJsonWithRainKey() |
|
108 | { |
|
@@ 107-143 (lines=37) @@ | ||
104 | $this->assertTrue($result); |
|
105 | } |
|
106 | ||
107 | public function testJsonWithRainKey() |
|
108 | { |
|
109 | $fakeJson = '{ |
|
110 | "cod":"200","calctime":"123456789","message":0.0032,"city_id":{"id":1851632,"name":"Shuzenji","coord":{"lon":138.933334,"lat":34.966671},"country":"JP"}, |
|
111 | "cnt":10, |
|
112 | "list":[{ |
|
113 | "city":{ |
|
114 | "country": "Berlin", |
|
115 | "population": "10,000" |
|
116 | } |
|
117 | },{ |
|
118 | "dt":1406080800, |
|
119 | "temp":{ |
|
120 | "day":297.77, |
|
121 | "min":293.52, |
|
122 | "max":297.77, |
|
123 | "night":293.52, |
|
124 | "eve":297.77, |
|
125 | "morn":297.77 |
|
126 | }, |
|
127 | "pressure":925.04, |
|
128 | "humidity":76, |
|
129 | "weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}], |
|
130 | "main":{"temp":306.15,"pressure":1013,"humidity":44,"temp_min":306,"temp_max":306}, |
|
131 | "clouds":{"all":90}, |
|
132 | "wind":{"speed":5.71,"deg":229.501}, |
|
133 | "rain":{"3h":3} |
|
134 | }] |
|
135 | }'; |
|
136 | $fakeJson = json_decode($fakeJson, true); |
|
137 | $history = new WeatherHistory($fakeJson, 'Berlin'); |
|
138 | ||
139 | $history->rewind(); |
|
140 | $result = $history->valid(); |
|
141 | ||
142 | $this->assertTrue($result); |
|
143 | } |
|
144 | } |
|
145 |