public function LayoutPluginTest::testDefaultWrappers in Display Suite 8.3
Same name and namespace in other branches
- 8.4 tests/src/Functional/LayoutPluginTest.php \Drupal\Tests\ds\Functional\LayoutPluginTest::testDefaultWrappers()
Tests settings default wrappers.
File
- tests/
src/ Functional/ LayoutPluginTest.php, line 91
Class
- LayoutPluginTest
- Tests DS layout plugins.
Namespace
Drupal\Tests\ds\FunctionalCode
public function testDefaultWrappers() {
// Create a node.
$settings = [
'type' => 'article',
];
$node = $this
->drupalCreateNode($settings);
// Select a layout.
$this
->dsSelectLayout();
// Go to the node.
$this
->drupalGet('node/' . $node
->id());
// Check we don't have empty wrappers.
$this
->assertSession()
->responseNotContains('<>');
// Select 1 col wrapper.
$assert = [
'regions' => [
'ds_content' => '<td colspan="8">' . t('Content') . '</td>',
],
];
$this
->dsSelectLayout([
'ds_layout' => 'ds_1col',
], $assert);
// Go to the node.
$this
->drupalGet('node/' . $node
->id());
// Check we don't have empty wrappers.
$elements = $this
->xpath('//div[@class="node node--type-article node--view-mode-full ds-1col clearfix"]/div/p');
$this
->assertCount(1, $elements);
$this
->assertTrimEqual($elements[0]
->getText(), $node
->get('body')->value);
// Switch theme.
$this->container
->get('theme_installer')
->install([
'ds_test_layout_theme',
]);
$config = \Drupal::configFactory()
->getEditable('system.theme');
$config
->set('default', 'ds_test_layout_theme')
->save();
drupal_flush_all_caches();
// Go to the node.
$this
->drupalGet('node/' . $node
->id());
$this
->assertSession()
->responseContains('id="overridden-ds-1-col-template"');
$elements = $this
->xpath('//div[@class="node node--type-article node--view-mode-full ds-1col clearfix"]/div/p');
$this
->assertCount(1, $elements);
$this
->assertTrimEqual($elements[0]
->getText(), $node
->get('body')->value);
}