File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Cmfcmf/OpenWeatherMap/Util Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,8 @@ public function __toString()
81
81
public function getUnit ()
82
82
{
83
83
// Units are inconsistent. Only celsius and fahrenheit are not abbreviated. This check fixes that.
84
- if ($ this ->unit == 'celsius ' ) {
84
+ // Also, the API started to return "metric" as temperature unit recently. Also fix that.
85
+ if ($ this ->unit == 'celsius ' || $ this ->unit == 'metric ' ) {
85
86
return "°C " ;
86
87
} else if ($ this ->unit == 'fahrenheit ' ) {
87
88
return 'F ' ;
Original file line number Diff line number Diff line change @@ -96,14 +96,21 @@ public function testGetUnitWithStringAsUnit()
96
96
$ this ->assertSame ("Hey! I'm cmfcmf " , $ this ->unit ->getUnit ());
97
97
}
98
98
99
- public function testCelsiusFixture ()
99
+ public function testCelsiusFix ()
100
100
{
101
101
$ this ->givenThereIsAUnitWithUnit ("celsius " );
102
102
103
103
$ this ->assertSame ("°C " , $ this ->unit ->getUnit ());
104
104
}
105
105
106
- public function testFahrenheitFixture ()
106
+ public function testMetricFix ()
107
+ {
108
+ $ this ->givenThereIsAUnitWithUnit ("metric " );
109
+
110
+ $ this ->assertSame ("°C " , $ this ->unit ->getUnit ());
111
+ }
112
+
113
+ public function testFahrenheitFix ()
107
114
{
108
115
$ this ->givenThereIsAUnitWithUnit ("fahrenheit " );
109
116
You can’t perform that action at this time.
0 commit comments