function NumberFieldTest::assertSetMinimumValue
Same name in other branches
- 9 core/modules/field/tests/src/Functional/Number/NumberFieldTest.php \Drupal\Tests\field\Functional\Number\NumberFieldTest::assertSetMinimumValue()
- 10 core/modules/field/tests/src/Functional/Number/NumberFieldTest.php \Drupal\Tests\field\Functional\Number\NumberFieldTest::assertSetMinimumValue()
- 11.x 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 426
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->drupalPostForm($field_configuration_url, $edit, t('Save settings'));
// Check if an error message is shown.
$this->assertNoRaw(t('%name is not a valid number.', [
'%name' => t('Minimum'),
]), 'Saved ' . gettype($minimum_value) . ' value as minimal value on a ' . $field->getType() . ' field');
// Check if a success message is shown.
$this->assertRaw(t('Saved %label configuration.', [
'%label' => $field->getLabel(),
]));
// Check if the minimum value was actually set.
$this->drupalGet($field_configuration_url);
$this->assertFieldById('edit-settings-min', $minimum_value, 'Minimal ' . gettype($minimum_value) . ' value was set on a ' . $field->getType() . ' field.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.