You are here

public function TemperatureTest::testConvert in Physical Fields 8

Tests unit conversion.

::covers convert.

File

tests/src/Unit/TemperatureTest.php, line 61

Class

TemperatureTest
Tests the temperature class.

Namespace

Drupal\Tests\physical\Unit

Code

public function testConvert() {
  $this
    ->assertEquals(new Temperature('230.85', 'C'), $this->temperatureKelvin
    ->convert('C')
    ->round(2));
  $this
    ->assertEquals(new Temperature('447.53', 'F'), $this->temperatureKelvin
    ->convert('F')
    ->round(2));
  $this
    ->assertEquals(new Temperature('32', 'F'), $this->temperatureCelsius
    ->convert('F')
    ->round());
  $this
    ->assertEquals(new Temperature('273.15', 'K'), $this->temperatureCelsius
    ->convert('K')
    ->round(2));
  $this
    ->assertEquals(new Temperature('18', 'C'), $this->temperatureFahrenheit
    ->convert('C')
    ->round());
  $this
    ->assertEquals(new Temperature('291.48', 'K'), $this->temperatureFahrenheit
    ->convert('K')
    ->round(2));
}