function NumberFieldTest::assertSetMinimumValue

Same name in other branches
  1. 9 core/modules/field/tests/src/Functional/Number/NumberFieldTest.php \Drupal\Tests\field\Functional\Number\NumberFieldTest::assertSetMinimumValue()
  2. 8.9.x core/modules/field/tests/src/Functional/Number/NumberFieldTest.php \Drupal\Tests\field\Functional\Number\NumberFieldTest::assertSetMinimumValue()
  3. 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.

@internal

1 call to NumberFieldTest::assertSetMinimumValue()
NumberFieldTest::testMinimumValues in core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
Tests setting minimum values through the interface.

File

core/modules/field/tests/src/Functional/Number/NumberFieldTest.php, line 442

Class

NumberFieldTest
Tests the creation of numeric fields.

Namespace

Drupal\Tests\field\Functional\Number

Code

public function assertSetMinimumValue(FieldConfigInterface $field, $minimum_value) : void {
    $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.