public function WeightTest::testConvert in Physical Fields 8
Tests unit conversion.
::covers convert.
File
- tests/
src/ Unit/ WeightTest.php, line 45
Class
- WeightTest
- Tests the weight class.
Namespace
Drupal\Tests\physical\UnitCode
public function testConvert() {
$this
->assertEquals(new Weight('5000000', 'mg'), $this->weight
->convert('mg')
->round());
$this
->assertEquals(new Weight('5000', 'g'), $this->weight
->convert('g')
->round());
$this
->assertEquals(new Weight('176.370', 'oz'), $this->weight
->convert('oz')
->round(3));
$this
->assertEquals(new Weight('11.023', 'lb'), $this->weight
->convert('lb')
->round(3));
}