diff --git a/core/modules/field/tests/src/Kernel/Number/NumberItemTest.php b/core/modules/field/tests/src/Kernel/Number/NumberItemTest.php index 8f56477931..ff09c90c5a 100644 --- a/core/modules/field/tests/src/Kernel/Number/NumberItemTest.php +++ b/core/modules/field/tests/src/Kernel/Number/NumberItemTest.php @@ -54,7 +54,7 @@ public function testNumberItem() { $entity->field_decimal = '20-40'; $violations = $entity->validate(); $this->assertIdentical(1, count($violations), 'Wrong decimal value causes validation error'); - $decimal = '31.30'; + $decimal = '31.3'; $entity->field_decimal = $decimal; $entity->name->value = $this->randomMachineName(); $entity->save(); @@ -72,26 +72,26 @@ public function testNumberItem() { $this->assertEqual($entity->field_float[0]->value, $float); $this->assertTrue($entity->field_decimal instanceof FieldItemListInterface, 'Field implements interface.'); $this->assertTrue($entity->field_decimal[0] instanceof FieldItemInterface, 'Field item implements interface.'); - $this->assertEqual($entity->field_decimal->value, $decimal); - $this->assertEqual($entity->field_decimal[0]->value, $decimal); + $this->assertEquals((float) $decimal, $entity->field_decimal->value); + $this->assertEquals((float) $decimal, $entity->field_decimal[0]->value); // Verify changing the number value. $new_integer = rand(11, 20); $new_float = rand(1001, 2000) / 100; - $new_decimal = '18.20'; + $new_decimal = '18.2'; $entity->field_integer->value = $new_integer; $this->assertEqual($entity->field_integer->value, $new_integer); $entity->field_float->value = $new_float; $this->assertEqual($entity->field_float->value, $new_float); $entity->field_decimal->value = $new_decimal; - $this->assertEqual($entity->field_decimal->value, $new_decimal); + $this->assertEquals((float) $new_decimal, $entity->field_decimal->value); // Read changed entity and assert changed values. $entity->save(); $entity = EntityTest::load($id); $this->assertEqual($entity->field_integer->value, $new_integer); $this->assertEqual($entity->field_float->value, $new_float); - $this->assertEqual($entity->field_decimal->value, $new_decimal); + $this->assertEquals((float) $new_decimal, $entity->field_decimal->value); // Test sample item generation. $entity = EntityTest::create(); diff --git a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php index 7caeb72427..31f5d2ef65 100644 --- a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php @@ -149,7 +149,7 @@ public function testNode() { $node = Node::load(1); $this->assertTrue($node->field_boolean->value); $this->assertEquals('99-99-99-99', $node->field_phone->value); - $this->assertEquals('1', $node->field_float->value); + $this->assertEquals(1, $node->field_float->value); $this->assertEquals('5', $node->field_integer->value); $this->assertEquals('Some more text', $node->field_text_list[0]->value); $this->assertEquals('7', $node->field_integer_list[0]->value);