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()
8181 public function getUnit ()
8282 {
8383 // 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 ' ) {
8586 return "°C " ;
8687 } else if ($ this ->unit == 'fahrenheit ' ) {
8788 return 'F ' ;
Original file line number Diff line number Diff line change @@ -96,14 +96,21 @@ public function testGetUnitWithStringAsUnit()
9696 $ this ->assertSame ("Hey! I'm cmfcmf " , $ this ->unit ->getUnit ());
9797 }
9898
99- public function testCelsiusFixture ()
99+ public function testCelsiusFix ()
100100 {
101101 $ this ->givenThereIsAUnitWithUnit ("celsius " );
102102
103103 $ this ->assertSame ("°C " , $ this ->unit ->getUnit ());
104104 }
105105
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 ()
107114 {
108115 $ this ->givenThereIsAUnitWithUnit ("fahrenheit " );
109116
You can’t perform that action at this time.
0 commit comments