1 number.test NumberFieldTestCase::testNumberIntegerField()

Test number_integer field.

File

core/modules/field/modules/number/tests/number.test, line 107
Tests for number.module.

Class

NumberFieldTestCase
Tests for number field types.

Code

function testNumberIntegerField() {
  // Display the "Add content type" form.
  $this->backdropGet('admin/structure/types/add');

  // Add a content type.
  $name = $this->randomName();
  $type = backdrop_strtolower($name);
  $edit = array('name' => $name, 'type' => $type);
  $this->backdropPost(NULL, $edit, t('Save and add fields'));

  // Add an integer field to the newly-created type.
  $label = $this->randomName();
  $field_name = backdrop_strtolower($label);
  $edit = array(
    'fields[_add_new_field][label]' => $label,
    'fields[_add_new_field][field_name]' => $field_name,
    'fields[_add_new_field][type]' => 'number_integer',
    'fields[_add_new_field][widget_type]' => 'number',
  );
  $this->backdropPost(NULL, $edit, t('Save'));

  // Set the formatter to "number_integer" and to "unformatted", and just
  // check that the settings summary does not generate warnings.
  $this->backdropGet("admin/structure/types/manage/$type/display/default");
  $edit = array(
    "fields[field_$field_name][type]" => 'number_integer',
  );
  $this->backdropPost(NULL, $edit, t('Save'));
  $edit = array(
    "fields[field_$field_name][type]" => 'number_unformatted',
  );
  $this->backdropPost(NULL, $edit, t('Save'));
}