View source
<?php
namespace Drupal\Tests\ds\Functional;
class FieldPluginTest extends TestBase {
public function testFieldPlugin() {
$edit = [
'title_label' => 'alternative article title',
];
$this
->drupalGet('admin/structure/types/manage/article');
$this
->submitForm($edit, 'Save content type');
$this
->dsSelectLayout();
$this
->drupalGet('admin/structure/types/manage/article/display');
$this
->assertSession()
->pageTextContains('Test field plugin');
$this
->assertSession()
->pageTextContains('Field altered');
$empty = [];
$edit = [
'ds_layout' => 'ds_2col_stacked',
];
$this
->dsSelectLayout($edit, $empty, 'admin/config/people/accounts/display');
$this
->drupalGet('admin/config/people/accounts/display');
$this
->assertSession()
->pageTextNotContains('Test code field from plugin');
$this
->assertSession()
->pageTextNotContains('Field altered');
$this
->dsSelectLayout();
$fields = [
'fields[node_title][region]' => 'right',
'fields[node_title][label]' => 'inline',
'fields[node_author][region]' => 'left',
'fields[node_links][region]' => 'left',
'fields[body][region]' => 'right',
'fields[test_field][region]' => 'right',
'fields[test_multiple_field][region]' => 'right',
'fields[test_field_empty_string][region]' => 'right',
'fields[test_field_empty_string][label]' => 'inline',
'fields[test_field_false][region]' => 'right',
'fields[test_field_false][label]' => 'inline',
'fields[test_field_null][region]' => 'right',
'fields[test_field_null][label]' => 'inline',
'fields[test_field_nothing][region]' => 'right',
'fields[test_field_nothing][label]' => 'inline',
'fields[test_field_zero_int][region]' => 'right',
'fields[test_field_zero_int][label]' => 'inline',
'fields[test_field_zero_string][region]' => 'right',
'fields[test_field_zero_string][label]' => 'inline',
'fields[test_field_zero_float][region]' => 'right',
'fields[test_field_zero_float][label]' => 'inline',
'fields[test_multiple_entity_test_field][region]' => 'right',
'fields[test_multiple_entity_test_field][label]' => 'inline',
];
$this
->dsSelectLayout();
$this
->dsConfigureUi($fields);
$settings = [
'type' => 'article',
];
$node = $this
->drupalCreateNode($settings);
$this
->drupalGet('node/' . $node
->id());
$this
->assertSession()
->responseContains('group-left');
$this
->assertSession()
->responseContains('group-right');
$this
->assertSession()
->pageTextContains('Test field plugin on node ' . $node
->id());
$this
->assertSession()
->pageTextContains('Test row one of multiple field plugin on node ' . $node
->id());
$this
->assertSession()
->pageTextContains('Test row two of multiple field plugin on node ' . $node
->id());
$this
->assertSession()
->pageTextContains('Test field plugin that returns an empty string');
$this
->assertSession()
->pageTextNotContains('Test field plugin that returns FALSE');
$this
->assertSession()
->pageTextNotContains('Test field plugin that returns NULL');
$this
->assertSession()
->pageTextNotContains('Test field plugin that returns nothing');
$this
->assertSession()
->pageTextNotContains('Test field plugin that returns an empty array');
$this
->assertSession()
->pageTextContains('Test field plugin that returns zero as an integer');
$this
->assertSession()
->pageTextContains('Test field plugin that returns zero as a string');
$this
->assertSession()
->pageTextContains('Test field plugin that returns zero as a floating point number');
$this
->assertSession()
->pageTextContains('alternative article title');
$this
->assertSession()
->pageTextContains('Multiple entity test field plugin');
$this
->dsSelectLayout([], [], 'admin/config/people/accounts/display');
$fields = [
'fields[test_multiple_entity_test_field][region]' => 'right',
'fields[test_multiple_entity_test_field][label]' => 'inline',
];
$this
->dsConfigureUi($fields, 'admin/config/people/accounts/display');
$this
->drupalGet('user/' . $this->adminUser
->id());
$this
->assertSession()
->pageTextContains('Multiple entity test field plugin');
}
}