function NumberFieldTest::assertSetMinimumValue in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field/src/Tests/Number/NumberFieldTest.php \Drupal\field\Tests\Number\NumberFieldTest::assertSetMinimumValue()
Helper function to set the minimum value of a field.
2 calls to NumberFieldTest::assertSetMinimumValue()
- NumberFieldTest::testCreateNumberDecimalField in core/
modules/ field/ src/ Tests/ Number/ NumberFieldTest.php - Tests setting the minimum value of a decimal field through the interface.
- NumberFieldTest::testCreateNumberFloatField in core/
modules/ field/ src/ Tests/ Number/ NumberFieldTest.php - Tests setting the minimum value of a float field through the interface.
File
- core/
modules/ field/ src/ Tests/ Number/ NumberFieldTest.php, line 551 - Contains \Drupal\field\Tests\Number\NumberFieldTest.
Class
- NumberFieldTest
- Tests the creation of numeric fields.
Namespace
Drupal\field\Tests\NumberCode
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 = array(
'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.', array(
'%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.', array(
'%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.');
}