You are here

function NumberFieldTest::testCreateNumberDecimalField in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Tests/Number/NumberFieldTest.php \Drupal\field\Tests\Number\NumberFieldTest::testCreateNumberDecimalField()

Tests setting the minimum value of a decimal field through the interface.

File

core/modules/field/src/Tests/Number/NumberFieldTest.php, line 526
Contains \Drupal\field\Tests\Number\NumberFieldTest.

Class

NumberFieldTest
Tests the creation of numeric fields.

Namespace

Drupal\field\Tests\Number

Code

function testCreateNumberDecimalField() {

  // Create a decimal field.
  $field_name = Unicode::strtolower($this
    ->randomMachineName());
  entity_create('field_storage_config', array(
    'field_name' => $field_name,
    'entity_type' => 'entity_test',
    'type' => 'decimal',
  ))
    ->save();
  $field = entity_create('field_config', array(
    'field_name' => $field_name,
    'entity_type' => 'entity_test',
    'bundle' => 'entity_test',
  ));
  $field
    ->save();

  // Set the minimum value to a decimal value.
  $this
    ->assertSetMinimumValue($field, 0.1);

  // Set the minimum value to an integer value.
  $this
    ->assertSetMinimumValue($field, 1);
}