public function NumberFieldTest::assertSetMinimumValue in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field/tests/src/Functional/Number/NumberFieldTest.php \Drupal\Tests\field\Functional\Number\NumberFieldTest::assertSetMinimumValue()
Helper function to set the minimum value of a field.
2 calls to NumberFieldTest::assertSetMinimumValue()
- NumberFieldTest::testCreateNumberDecimalField in core/
modules/ field/ tests/ src/ Functional/ Number/ NumberFieldTest.php - Tests setting the minimum value of a decimal field through the interface.
- NumberFieldTest::testCreateNumberFloatField in core/
modules/ field/ tests/ src/ Functional/ Number/ NumberFieldTest.php - Tests setting the minimum value of a float field through the interface.
File
- core/
modules/ field/ tests/ src/ Functional/ Number/ NumberFieldTest.php, line 430
Class
- NumberFieldTest
- Tests the creation of numeric fields.
Namespace
Drupal\Tests\field\Functional\NumberCode
public function assertSetMinimumValue($field, $minimum_value) {
$field_configuration_url = 'entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field
->getName();
// Set the minimum value.
$edit = [
'settings[min]' => $minimum_value,
];
$this
->drupalGet($field_configuration_url);
$this
->submitForm($edit, 'Save settings');
// Check if an error message is shown.
$this
->assertSession()
->pageTextNotContains("Minimum is not a valid number.");
// Check if a success message is shown.
$this
->assertSession()
->pageTextContains("Saved {$field->getLabel()} configuration.");
// Check if the minimum value was actually set.
$this
->drupalGet($field_configuration_url);
$this
->assertSession()
->fieldValueEquals('edit-settings-min', $minimum_value);
}