You are here

public function FieldPlaceholderTestCase::testPlaceholderBasic in Field placeholder 7

Same name and namespace in other branches
  1. 7.2 field_placeholder.test \FieldPlaceholderTestCase::testPlaceholderBasic()

Performs the basic tests.

File

./field_placeholder.test, line 89
File that holds functional tests for Field placeholder module.

Class

FieldPlaceholderTestCase
@file File that holds functional tests for Field placeholder module.

Code

public function testPlaceholderBasic() {
  $bundle_path1 = 'admin/structure/types/manage/' . $this->hyphen_type;

  // Create a basic text field.
  $edit = array(
    'fields[_add_new_field][type]' => 'text',
    'fields[_add_new_field][widget_type]' => 'text_textfield',
    'fields[_add_new_field][label]' => 'Text',
    'fields[_add_new_field][field_name]' => 'text',
  );
  $instance_settings = array(
    'instance[placeholder]' => 'Textfield placeholder',
  );
  $this
    ->fieldUIAddNewField($bundle_path1, $edit, array(), $instance_settings);

  // Create a long text field.
  $edit = array(
    'fields[_add_new_field][type]' => 'text_long',
    'fields[_add_new_field][widget_type]' => 'text_textarea',
    'fields[_add_new_field][label]' => 'Long text',
    'fields[_add_new_field][field_name]' => 'longtext',
  );
  $instance_settings = array(
    'instance[placeholder]' => 'Textarea placeholder',
  );
  $this
    ->fieldUIAddNewField($bundle_path1, $edit, array(), $instance_settings);

  // Create a long text with summary field.
  $edit = array(
    'fields[_add_new_field][type]' => 'text_with_summary',
    'fields[_add_new_field][widget_type]' => 'text_textarea_with_summary',
    'fields[_add_new_field][label]' => 'Text with summary',
    'fields[_add_new_field][field_name]' => 'summary',
  );
  $instance_settings = array(
    'instance[placeholder]' => 'Summary placeholder',
    'instance[settings][display_summary]' => 1,
  );
  $this
    ->fieldUIAddNewField($bundle_path1, $edit, array(), $instance_settings);

  // Create an integer field.
  $edit = array(
    'fields[_add_new_field][type]' => 'number_integer',
    'fields[_add_new_field][widget_type]' => 'number',
    'fields[_add_new_field][label]' => 'Number',
    'fields[_add_new_field][field_name]' => 'integer',
  );
  $instance_settings = array(
    'instance[placeholder]' => 'Integer placeholder',
  );
  $this
    ->fieldUIAddNewField($bundle_path1, $edit, array(), $instance_settings);

  // Go to node creation page.
  $this
    ->drupalGet('node/add/' . $this->hyphen_type);

  // Assertions.
  $this
    ->assertRaw('placeholder="Textfield placeholder"', 'Text field placeholder displayed');
  $this
    ->assertRaw('placeholder="Textarea placeholder"', 'Textarea field placeholder displayed');
  $this
    ->assertRaw('placeholder="Summary placeholder"', 'Text with summary field placeholder displayed');
  $this
    ->assertRaw('placeholder="Integer placeholder"', 'Integer field placeholder displayed');
}