function DataConvertTest::testConvertToFloat
Test the conversion to float.
@covers ::execute
File
-
tests/
src/ Unit/ Integration/ RulesAction/ DataConvertTest.php, line 72
Class
- DataConvertTest
- @coversDefaultClass \Drupal\rules\Plugin\RulesAction\DataConvert @group RulesAction
Namespace
Drupal\Tests\rules\Unit\Integration\RulesActionCode
public function testConvertToFloat() {
$value = '1.5';
$converted = $this->executeAction($value, 'float');
$this->assertIsFloat($converted->getValue());
$this->assertEquals('float', $converted->getDataDefinition()
->getDataType());
$this->assertEquals(1.5, $converted->getValue());
$converted = $this->executeAction('+1.5', 'float');
$this->assertIsFloat($converted->getValue());
$this->assertEquals('float', $converted->getDataDefinition()
->getDataType());
$this->assertEquals(1.5, $converted->getValue());
}