LayoutPluginTest.php in Display Suite 8.2
File
src/Tests/LayoutPluginTest.php
View source
<?php
namespace Drupal\ds\Tests;
class LayoutPluginTest extends FastTestBase {
public function testFieldPlugin() {
$this
->drupalGet('admin/structure/types/manage/article/display');
$this
->assertRaw('Test One column', 'Test One column layout found');
$this
->assertRaw('Test Two column', 'Test Two column layout found');
$layout = array(
'layout' => 'dstest_2col',
);
$assert = array(
'regions' => array(
'left' => '<td colspan="8">' . t('Left') . '</td>',
'right' => '<td colspan="8">' . t('Right') . '</td>',
),
);
$fields = array(
'fields[node_author][region]' => 'left',
'fields[node_links][region]' => 'left',
'fields[body][region]' => 'right',
);
$this
->dsSelectLayout($layout, $assert);
$this
->dsConfigureUi($fields);
$settings = array(
'type' => 'article',
);
$node = $this
->drupalCreateNode($settings);
$this
->drupalGet('node/' . $node
->id());
$this
->assertRaw('group-left', 'Template found (region left)');
$this
->assertRaw('group-right', 'Template found (region right)');
$this
->assertRaw('dstest-2col.css', 'Css file included');
$settings = array(
'type' => 'article',
'title' => 'Alter me!',
);
$node = $this
->drupalCreateNode($settings);
$this
->drupalGet('node/' . $node
->id());
$this
->assertRaw('cool!', 'Region altered');
}
public function testResetLayout() {
$layout = array(
'layout' => 'ds_reset',
);
$assert = array(
'regions' => array(
'ds_content' => '<td colspan="8">' . t('Content') . '</td>',
),
);
$fields = array(
'fields[node_author][region]' => 'ds_content',
);
$this
->dsSelectLayout($layout, $assert);
$this
->dsConfigureUi($fields);
$settings = array(
'type' => 'article',
);
$node = $this
->drupalCreateNode($settings);
$this
->drupalGet('node/' . $node
->id());
}
public function testDefaultWrappers() {
$settings = array(
'type' => 'article',
);
$node = $this
->drupalCreateNode($settings);
$this
->dsSelectLayout();
$this
->drupalGet('node/' . $node
->id());
$this
->assertNoRaw('<>', 'No empty wrappers found');
}
}