Conditions | 1 |
Paths | 1 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function testFromApi(): void |
||
18 | { |
||
19 | $data = <<<'EOD' |
||
20 | { |
||
21 | "id" : "5357527", |
||
22 | "name" : "Hollywood", |
||
23 | "stateCode" : "CA", |
||
24 | "state" : "California", |
||
25 | "coords" : { |
||
26 | "long" : -118.3267434, |
||
27 | "lat" : 34.0983425 |
||
28 | }, |
||
29 | "country" : { |
||
30 | "code" : "US", |
||
31 | "name" : "United States" |
||
32 | } |
||
33 | } |
||
34 | EOD; |
||
35 | |||
36 | $city = City::fromApi(json_decode($data, true)); |
||
37 | $this->assertSame(5357527, $city->getId()); |
||
38 | $this->assertSame('Hollywood', $city->getName()); |
||
39 | $this->assertSame('California', $city->getState()); |
||
40 | $this->assertNotNull($city->getCounty()); |
||
41 | $this->assertNotNull($city->getGeo()); |
||
42 | $this->assertSame('CA', $city->getStateCode()); |
||
43 | } |
||
44 | } |
||
45 |