@@ 106-141 (lines=36) @@ | ||
103 | $this->assertTrue($result); |
|
104 | } |
|
105 | ||
106 | public function testJsonHasCountryAndPopulation() |
|
107 | { |
|
108 | $fakeJson = '{ |
|
109 | "cod":"200","calctime":"123456789","message":0.0032,"city_id":{"id":1851632,"name":"Shuzenji","coord":{"lon":138.933334,"lat":34.966671},"country":"JP"}, |
|
110 | "cnt":10, |
|
111 | "list":[{ |
|
112 | "city":{ |
|
113 | "country": "Berlin", |
|
114 | "population": "10,000" |
|
115 | } |
|
116 | },{ |
|
117 | "dt":1406080800, |
|
118 | "temp":{ |
|
119 | "day":297.77, |
|
120 | "min":293.52, |
|
121 | "max":297.77, |
|
122 | "night":293.52, |
|
123 | "eve":297.77, |
|
124 | "morn":297.77 |
|
125 | }, |
|
126 | "pressure":925.04, |
|
127 | "humidity":76, |
|
128 | "weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}], |
|
129 | "main":{"temp":306.15,"pressure":1013,"humidity":44,"temp_min":306,"temp_max":306}, |
|
130 | "clouds":{"all":90}, |
|
131 | "wind":{"speed":5.71,"deg":229.501} |
|
132 | }] |
|
133 | }'; |
|
134 | $fakeJson = json_decode($fakeJson, true); |
|
135 | $history = new WeatherHistory($fakeJson, 'Berlin'); |
|
136 | ||
137 | $history->rewind(); |
|
138 | $result = $history->valid(); |
|
139 | ||
140 | $this->assertTrue($result); |
|
141 | } |
|
142 | ||
143 | public function testJsonWithRainKey() |
|
144 | { |
|
@@ 143-179 (lines=37) @@ | ||
140 | $this->assertTrue($result); |
|
141 | } |
|
142 | ||
143 | public function testJsonWithRainKey() |
|
144 | { |
|
145 | $fakeJson = '{ |
|
146 | "cod":"200","calctime":"123456789","message":0.0032,"city_id":{"id":1851632,"name":"Shuzenji","coord":{"lon":138.933334,"lat":34.966671},"country":"JP"}, |
|
147 | "cnt":10, |
|
148 | "list":[{ |
|
149 | "city":{ |
|
150 | "country": "Berlin", |
|
151 | "population": "10,000" |
|
152 | } |
|
153 | },{ |
|
154 | "dt":1406080800, |
|
155 | "temp":{ |
|
156 | "day":297.77, |
|
157 | "min":293.52, |
|
158 | "max":297.77, |
|
159 | "night":293.52, |
|
160 | "eve":297.77, |
|
161 | "morn":297.77 |
|
162 | }, |
|
163 | "pressure":925.04, |
|
164 | "humidity":76, |
|
165 | "weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}], |
|
166 | "main":{"temp":306.15,"pressure":1013,"humidity":44,"temp_min":306,"temp_max":306}, |
|
167 | "clouds":{"all":90}, |
|
168 | "wind":{"speed":5.71,"deg":229.501}, |
|
169 | "rain":{"3h":3} |
|
170 | }] |
|
171 | }'; |
|
172 | $fakeJson = json_decode($fakeJson, true); |
|
173 | $history = new WeatherHistory($fakeJson, 'Berlin'); |
|
174 | ||
175 | $history->rewind(); |
|
176 | $result = $history->valid(); |
|
177 | ||
178 | $this->assertTrue($result); |
|
179 | } |
|
180 | } |
|
181 |