TwigRenderTest.php in Display Suite 8.4
File
tests/src/Functional/TwigRenderTest.php
View source
<?php
namespace Drupal\Tests\ds\Functional;
class TwigRenderTest extends TestBase {
public function testFieldNameTargeting() {
$settings = [
'type' => 'article',
'promote' => 1,
];
$node = $this
->drupalCreateNode($settings);
$layout = [
'ds_layout' => 'dstest_1col_title',
];
$layout_assert = [
'regions' => [
'ds_content' => '<td colspan="8">' . t('Content') . '</td>',
],
];
$this
->dsSelectLayout($layout, $layout_assert);
$fields = [
'fields[node_title][region]' => 'ds_content',
];
$this
->dsConfigureUi($fields);
$this
->drupalGet('node/' . $node
->id());
$elements = $this
->xpath('//div[@class="field field--name-node-title field--type-ds field--label-hidden field__item"]/h2');
$this
->assertEquals(count($elements), 1);
$this
->assertSession()
->pageTextContains($node
->getTitle());
$edit = [
'fs3[use_field_names]' => FALSE,
];
$this
->drupalGet('admin/structure/ds/settings');
$this
->submitForm($edit, 'Save configuration');
$this
->drupalGet('node/' . $node
->id());
$elements = $this
->xpath('//div[@class="field field--name-node-title field--type-ds field--label-hidden field__item"]/h2');
$this
->assertEquals(count($elements), 0);
}
}