public function FieldFormatterFromViewDisplayUITest::testFieldFormatterFromViewDisplay in (Entity Reference) Field Formatters 3.x
Same name and namespace in other branches
- 8.2 src/Tests/FieldFormatterFromViewDisplayUITest.php \Drupal\field_formatter\Tests\FieldFormatterFromViewDisplayUITest::testFieldFormatterFromViewDisplay()
- 8 src/Tests/FieldFormatterFromViewDisplayUITest.php \Drupal\field_formatter\Tests\FieldFormatterFromViewDisplayUITest::testFieldFormatterFromViewDisplay()
Tests a field_formatter from view display.
File
- src/
Tests/ FieldFormatterFromViewDisplayUITest.php, line 46
Class
- FieldFormatterFromViewDisplayUITest
- Ensures that field_formatter UI work correctly.
Namespace
Drupal\field_formatter\TestsCode
public function testFieldFormatterFromViewDisplay() {
// Add term.
$this
->drupalGet('admin/structure/taxonomy/manage/test_vocabulary/add');
$term_name = strtolower($this
->randomMachineName());
$field = strtolower($this
->randomMachineName());
$edit_term = [
'name[0][value]' => $term_name,
'field_test_field[0][value]' => $field,
];
$this
->drupalPostForm(NULL, $edit_term, $this
->t('Save'));
$this
->assertText("Created new term {$term_name}.", 'Created term.');
// Add content.
$this
->drupalGet('node/add/test_content_type');
$content_name = strtolower($this
->randomMachineName());
$edit_content = [
'title[0][value]' => $content_name,
'field_field_test_ref[0][target_id]' => $term_name,
];
$this
->drupalPostForm(NULL, $edit_content, $this
->t('Save'));
$this
->assertRaw('<div class="field__label">test_field</div>', 'Field is correctly displayed on node page.');
$this
->assertRaw('<div class="field__item">' . $field . '</div>', "Field's content was found.");
}