View source
<?php
namespace Drupal\Tests\ui_patterns_settings\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\ui_patterns\Traits\TwigDebugTrait;
class UiPatternsSettingsRenderTest extends BrowserTestBase {
protected $defaultTheme = 'stable';
protected $strictConfigSchema = FALSE;
use TwigDebugTrait;
protected static $modules = [
'node',
'ui_patterns',
'ui_patterns_ds',
'ui_patterns_library',
'ui_patterns_layouts',
'ui_patterns_settings',
'field_ui',
'colorwidget',
'token',
'ds',
'ui_patterns_settings_render_test',
];
public function testRender() {
$assert_session = $this
->assertSession();
$this
->drupalCreateContentType([
'type' => 'article',
]);
$created_node = $this
->drupalCreateNode([
'title' => t('Hello Settings'),
'type' => 'article',
]);
$this
->enableTwigDebugMode();
$user = $this
->drupalCreateUser([], NULL, TRUE);
$this
->drupalLogin($user);
$mappings = [
'[textfield]' => [
'input' => 'Text',
'result' => 'Textfield: Text',
],
'[number]' => [
'input' => '10',
'result' => 'Number: 10',
],
'[token][input]' => [
'input' => '[node:nid]',
'result' => 'Token: 1',
],
'[url][input]' => [
'input' => 'internal:/node/1',
'result' => 'Url: /node/1',
],
'[boolean]' => [
'input' => '1',
'result' => 'Boolean: 1',
],
'[select]' => [
'input' => 'key',
'result' => 'Select: key',
],
'[enumeration]' => [
'input' => 'key',
'result' => 'Enumeration: key',
],
'[colorwidget][colorwidget]' => [
'input' => 'key',
'result' => 'Colorwidget: key',
],
'[checkboxes][box1]' => [
'input' => TRUE,
'result' => 'Checkboxes: Box1',
],
'[attributes]' => [
'input' => 'class="class"',
'result' => 'Attributes: class="class"',
],
'[group_sub]' => [
'input' => 'group_sub',
'result' => 'Group sub: group_sub',
],
];
$edit = [
'ds_layout' => 'pattern_foo_settings',
];
$this
->drupalPostForm('/admin/structure/types/manage/article/display', $edit, 'Save');
$edit = [];
foreach ($mappings as $key => $mapping) {
$edit['layout_configuration[pattern][settings]' . $key] = $mapping['input'];
}
$this
->drupalPostForm('/admin/structure/types/manage/article/display', $edit, 'Save');
$this
->drupalGet('/node/' . $created_node
->id());
foreach ($mappings as $key => $mapping) {
$assert_session
->responseContains($mapping['result']);
}
$assert_session
->responseContains('Configuration: config_value');
}
}