class LayoutBuilderTest in Drupal 9
Same name in this branch
- 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest
- 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderTest
Same name and namespace in other branches
- 8 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest
Tests the Layout Builder UI.
@group layout_builder
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, AssertLegacyTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, PhpUnitCompatibilityTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest
Expanded class hierarchy of LayoutBuilderTest
File
- core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderTest.php, line 16
Namespace
Drupal\Tests\layout_builder\FunctionalView source
class LayoutBuilderTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'views',
'layout_builder',
'layout_builder_views_test',
'layout_test',
'block',
'block_test',
'node',
'layout_builder_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this
->drupalPlaceBlock('local_tasks_block');
// Create two nodes.
$this
->createContentType([
'type' => 'bundle_with_section_field',
'name' => 'Bundle with section field',
]);
$this
->createNode([
'type' => 'bundle_with_section_field',
'title' => 'The first node title',
'body' => [
[
'value' => 'The first node body',
],
],
]);
$this
->createNode([
'type' => 'bundle_with_section_field',
'title' => 'The second node title',
'body' => [
[
'value' => 'The second node body',
],
],
]);
}
/**
* Tests deleting a field in-use by an overridden layout.
*/
public function testDeleteField() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node fields',
]));
// Enable layout builder overrides.
LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')
->enableLayoutBuilder()
->setOverridable()
->save();
// Ensure there is a layout override.
$this
->drupalGet('node/1/layout');
$page
->pressButton('Save layout');
// Delete one of the fields in use.
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/fields/node.bundle_with_section_field.body/delete');
$page
->pressButton('Delete');
// The node should still be accessible.
$this
->drupalGet('node/1');
$assert_session
->statusCodeEquals(200);
$this
->drupalGet('node/1/layout');
$assert_session
->statusCodeEquals(200);
}
/**
* Tests Layout Builder overrides without access to edit the default layout.
*/
public function testOverridesWithoutDefaultsAccess() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
]));
LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')
->enableLayoutBuilder()
->setOverridable()
->save();
$this
->drupalGet('node/1');
$page
->clickLink('Layout');
$assert_session
->elementTextContains('css', '.layout-builder__message.layout-builder__message--overrides', 'You are editing the layout for this Bundle with section field content item.');
$assert_session
->linkNotExists('Edit the template for all Bundle with section field content items instead.');
}
/**
* Tests functionality of Layout Builder for overrides.
*/
public function testOverrides() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
// From the manage display page, go to manage the layout.
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
// @todo This should not be necessary.
$this->container
->get('entity_field.manager')
->clearCachedFieldDefinitions();
// Add a block with a custom label.
$this
->drupalGet('node/1');
$page
->clickLink('Layout');
// The layout form should not contain fields for the title of the node by
// default.
$assert_session
->fieldNotExists('title[0][value]');
$assert_session
->elementTextContains('css', '.layout-builder__message.layout-builder__message--overrides', 'You are editing the layout for this Bundle with section field content item. Edit the template for all Bundle with section field content items instead.');
$assert_session
->linkExists('Edit the template for all Bundle with section field content items instead.');
$page
->clickLink('Add block');
$page
->clickLink('Powered by Drupal');
$page
->fillField('settings[label]', 'This is an override');
$page
->checkField('settings[label_display]');
$page
->pressButton('Add block');
$page
->pressButton('Save layout');
$assert_session
->pageTextContains('This is an override');
// Get the UUID of the component.
$components = Node::load(1)
->get('layout_builder__layout')
->getSection(0)
->getComponents();
end($components);
$uuid = key($components);
$this
->drupalGet('layout_builder/update/block/overrides/node.1/0/content/' . $uuid);
$page
->uncheckField('settings[label_display]');
$page
->pressButton('Update');
$assert_session
->pageTextNotContains('This is an override');
$page
->pressButton('Save layout');
$assert_session
->pageTextNotContains('This is an override');
}
/**
* Tests the Layout Builder UI for an entity type without a bundle.
*/
public function testNonBundleEntityType() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
// Log in as a user that can edit layout templates.
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer user display',
]));
$this
->drupalGet('admin/config/people/accounts/display/default');
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$page
->clickLink('Manage layout');
$assert_session
->pageTextContains('You are editing the layout template for all users.');
$this
->drupalGet('user');
$page
->clickLink('Layout');
$assert_session
->pageTextContains('You are editing the layout for this user. Edit the template for all users instead.');
// Log in as a user that cannot edit layout templates.
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
]));
$this
->drupalGet('user');
$page
->clickLink('Layout');
$assert_session
->pageTextContains('You are editing the layout for this user.');
$assert_session
->pageTextNotContains('Edit the template for all users instead.');
}
/**
* Tests that the Layout Builder preserves entity values.
*/
public function testPreserverEntityValues() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
// From the manage display page, go to manage the layout.
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
// @todo This should not be necessary.
$this->container
->get('entity_field.manager')
->clearCachedFieldDefinitions();
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('The first node body');
// Create a layout override which will store the current node in the
// tempstore.
$page
->clickLink('Layout');
$page
->clickLink('Add block');
$page
->clickLink('Powered by Drupal');
$page
->pressButton('Add block');
// Update the node to make a change that is not in the tempstore version.
$node = Node::load(1);
$node
->set('body', 'updated body');
$node
->save();
$page
->clickLink('View');
$assert_session
->pageTextNotContains('The first node body');
$assert_session
->pageTextContains('updated body');
$page
->clickLink('Layout');
$page
->pressButton('Save layout');
// Ensure that saving the layout does not revert other field values.
$assert_session
->addressEquals('node/1');
$assert_session
->pageTextNotContains('The first node body');
$assert_session
->pageTextContains('updated body');
}
/**
* {@inheritdoc}
*/
public function testLayoutBuilderUi() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'administer node fields',
]));
$this
->drupalGet('node/1');
$assert_session
->elementNotExists('css', '.layout-builder-block');
$assert_session
->pageTextContains('The first node body');
$assert_session
->pageTextNotContains('Powered by Drupal');
$assert_session
->linkNotExists('Layout');
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// From the manage display page, go to manage the layout.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$assert_session
->linkNotExists('Manage layout');
$assert_session
->fieldDisabled('layout[allow_custom]');
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$assert_session
->linkExists('Manage layout');
$this
->clickLink('Manage layout');
$assert_session
->addressEquals("{$field_ui_prefix}/display/default/layout");
$assert_session
->elementTextContains('css', '.layout-builder__message.layout-builder__message--defaults', 'You are editing the layout template for all Bundle with section field content items.');
// The body field is only present once.
$assert_session
->elementsCount('css', '.field--name-body', 1);
// The extra field is only present once.
$assert_session
->pageTextContainsOnce('Placeholder for the "Extra label" field');
// Blocks have layout builder specific block class.
$assert_session
->elementExists('css', '.layout-builder-block');
// Save the defaults.
$page
->pressButton('Save layout');
$assert_session
->addressEquals("{$field_ui_prefix}/display/default");
// Load the default layouts again after saving to confirm fields are only
// added on new layouts.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$assert_session
->linkExists('Manage layout');
$this
->clickLink('Manage layout');
$assert_session
->addressEquals("{$field_ui_prefix}/display/default/layout");
// The body field is only present once.
$assert_session
->elementsCount('css', '.field--name-body', 1);
// The extra field is only present once.
$assert_session
->pageTextContainsOnce('Placeholder for the "Extra label" field');
// Add a new block.
$assert_session
->linkExists('Add block');
$this
->clickLink('Add block');
$assert_session
->linkExists('Powered by Drupal');
$this
->clickLink('Powered by Drupal');
$page
->fillField('settings[label]', 'This is the label');
$page
->checkField('settings[label_display]');
$page
->pressButton('Add block');
$assert_session
->pageTextContains('Powered by Drupal');
$assert_session
->pageTextContains('This is the label');
$assert_session
->addressEquals("{$field_ui_prefix}/display/default/layout");
// Save the defaults.
$page
->pressButton('Save layout');
$assert_session
->pageTextContains('The layout has been saved.');
$assert_session
->addressEquals("{$field_ui_prefix}/display/default");
// The node uses the defaults, no overrides available.
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('The first node body');
$assert_session
->pageTextContains('Powered by Drupal');
$assert_session
->pageTextContains('Extra, Extra read all about it.');
$assert_session
->pageTextNotContains('Placeholder for the "Extra label" field');
$assert_session
->linkNotExists('Layout');
// Enable overrides.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$this
->drupalGet('node/1');
// Remove the section from the defaults.
$assert_session
->linkExists('Layout');
$this
->clickLink('Layout');
$assert_session
->pageTextContains('Placeholder for the "Extra label" field');
$assert_session
->linkExists('Remove Section 1');
$this
->clickLink('Remove Section 1');
$page
->pressButton('Remove');
// Add a new section.
$this
->clickLink('Add section');
$this
->assertCorrectLayouts();
$assert_session
->linkExists('Two column');
$this
->clickLink('Two column');
$assert_session
->buttonExists('Add section');
$page
->pressButton('Add section');
$page
->pressButton('Save');
$assert_session
->pageTextNotContains('The first node body');
$assert_session
->pageTextNotContains('Powered by Drupal');
$assert_session
->pageTextNotContains('Extra, Extra read all about it.');
$assert_session
->pageTextNotContains('Placeholder for the "Extra label" field');
// Assert that overrides cannot be turned off while overrides exist.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$assert_session
->checkboxChecked('layout[allow_custom]');
$assert_session
->fieldDisabled('layout[allow_custom]');
// Alter the defaults.
$this
->drupalGet("{$field_ui_prefix}/display/default/layout");
$assert_session
->linkExists('Add block');
$this
->clickLink('Add block');
$assert_session
->linkExists('Title');
$this
->clickLink('Title');
$page
->pressButton('Add block');
// The title field is present.
$assert_session
->elementExists('css', '.field--name-title');
$page
->pressButton('Save layout');
// View the other node, which is still using the defaults.
$this
->drupalGet('node/2');
$assert_session
->pageTextContains('The second node title');
$assert_session
->pageTextContains('The second node body');
$assert_session
->pageTextContains('Powered by Drupal');
$assert_session
->pageTextContains('Extra, Extra read all about it.');
$assert_session
->pageTextNotContains('Placeholder for the "Extra label" field');
// The overridden node does not pick up the changes to defaults.
$this
->drupalGet('node/1');
$assert_session
->elementNotExists('css', '.field--name-title');
$assert_session
->pageTextNotContains('The first node body');
$assert_session
->pageTextNotContains('Powered by Drupal');
$assert_session
->pageTextNotContains('Extra, Extra read all about it.');
$assert_session
->pageTextNotContains('Placeholder for the "Extra label" field');
$assert_session
->linkExists('Layout');
// Reverting the override returns it to the defaults.
$this
->clickLink('Layout');
$assert_session
->linkExists('Add block');
$this
->clickLink('Add block');
$assert_session
->linkExists('ID');
$this
->clickLink('ID');
$page
->pressButton('Add block');
// The title field is present.
$assert_session
->elementExists('css', '.field--name-nid');
$assert_session
->pageTextContains('ID');
$assert_session
->pageTextContains('1');
$page
->pressButton('Revert to defaults');
$page
->pressButton('Revert');
$assert_session
->addressEquals('node/1');
$assert_session
->pageTextContains('The layout has been reverted back to defaults.');
$assert_session
->elementExists('css', '.field--name-title');
$assert_session
->elementNotExists('css', '.field--name-nid');
$assert_session
->pageTextContains('The first node body');
$assert_session
->pageTextContains('Powered by Drupal');
$assert_session
->pageTextContains('Extra, Extra read all about it.');
// Assert that overrides can be turned off now that all overrides are gone.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[allow_custom]' => FALSE,
], 'Save');
$this
->drupalGet('node/1');
$assert_session
->linkNotExists('Layout');
// Add a new field.
$edit = [
'new_storage_type' => 'string',
'label' => 'My text field',
'field_name' => 'my_text',
];
$this
->drupalGet("{$field_ui_prefix}/fields/add-field");
$this
->submitForm($edit, 'Save and continue');
$page
->pressButton('Save field settings');
$page
->pressButton('Save settings');
$this
->drupalGet("{$field_ui_prefix}/display/default/layout");
$assert_session
->pageTextContains('My text field');
$assert_session
->elementExists('css', '.field--name-field-my-text');
// Delete the field.
$this
->drupalGet("{$field_ui_prefix}/fields/node.bundle_with_section_field.field_my_text/delete");
$this
->submitForm([], 'Delete');
$this
->drupalGet("{$field_ui_prefix}/display/default/layout");
$assert_session
->pageTextNotContains('My text field');
$assert_session
->elementNotExists('css', '.field--name-field-my-text');
$this
->clickLink('Add section');
$this
->clickLink('One column');
$page
->fillField('layout_settings[label]', 'My Cool Section');
$page
->pressButton('Add section');
$expected_labels = [
'My Cool Section',
'Content region in My Cool Section',
'Section 2',
'Content region in Section 2',
];
$labels = [];
foreach ($page
->findAll('css', '[role="group"]') as $element) {
$labels[] = $element
->getAttribute('aria-label');
}
$this
->assertSame($expected_labels, $labels);
}
/**
* Test decorating controller.entity_form while layout_builder is installed.
*/
public function testHtmlEntityFormControllerDecoration() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
// Install module that decorates controller.entity_form.
\Drupal::service('module_installer')
->install([
'layout_builder_decoration_test',
]);
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$assert_session
->pageTextContains('Manage Display');
}
/**
* Tests that layout builder checks entity view access.
*/
public function testAccess() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// Allow overrides for the layout.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
]));
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('The first node body');
$assert_session
->pageTextNotContains('Powered by Drupal');
$node = Node::load(1);
$node
->setUnpublished();
$node
->save();
$this
->drupalGet('node/1');
$assert_session
->pageTextNotContains('The first node body');
$assert_session
->pageTextContains('Access denied');
$this
->drupalGet('node/1/layout');
$assert_session
->pageTextNotContains('The first node body');
$assert_session
->pageTextContains('Access denied');
}
/**
* Tests that a non-default view mode works as expected.
*/
public function testNonDefaultViewMode() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// Allow overrides for the layout.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$page
->checkField('layout[enabled]');
$page
->pressButton('Save');
$page
->checkField('layout[allow_custom]');
$page
->pressButton('Save');
$this
->clickLink('Manage layout');
// Confirm the body field only is shown once.
$assert_session
->elementsCount('css', '.field--name-body', 1);
$page
->pressButton('Discard changes');
$page
->pressButton('Confirm');
$this
->clickLink('Teaser');
// Enabling Layout Builder for the default mode does not affect the teaser.
$assert_session
->addressEquals("{$field_ui_prefix}/display/teaser");
$assert_session
->elementNotExists('css', '#layout-builder__layout');
$assert_session
->checkboxNotChecked('layout[enabled]');
$page
->checkField('layout[enabled]');
$page
->pressButton('Save');
$assert_session
->linkExists('Manage layout');
$page
->clickLink('Manage layout');
// Confirm the body field only is shown once.
$assert_session
->elementsCount('css', '.field--name-body', 1);
// Enable a disabled view mode.
$page
->pressButton('Discard changes');
$page
->pressButton('Confirm');
$assert_session
->addressEquals("{$field_ui_prefix}/display/teaser");
$page
->clickLink('Default');
$assert_session
->addressEquals("{$field_ui_prefix}/display");
$assert_session
->linkNotExists('Full content');
$page
->checkField('display_modes_custom[full]');
$page
->pressButton('Save');
$assert_session
->linkExists('Full content');
$page
->clickLink('Full content');
$assert_session
->addressEquals("{$field_ui_prefix}/display/full");
$page
->checkField('layout[enabled]');
$page
->pressButton('Save');
$assert_session
->linkExists('Manage layout');
$page
->clickLink('Manage layout');
// Confirm the body field only is shown once.
$assert_session
->elementsCount('css', '.field--name-body', 1);
}
/**
* Tests that component's dependencies are respected during removal.
*/
public function testPluginDependencies() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this->container
->get('module_installer')
->install([
'menu_ui',
]);
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'administer menu',
]));
// Create a new menu.
$this
->drupalGet('admin/structure/menu/add');
$page
->fillField('label', 'My Menu');
$page
->fillField('id', 'my-menu');
$page
->pressButton('Save');
$this
->drupalGet('admin/structure/menu/add');
$page
->fillField('label', 'My Menu');
$page
->fillField('id', 'my-other-menu');
$page
->pressButton('Save');
$page
->clickLink('Add link');
$page
->fillField('title[0][value]', 'My link');
$page
->fillField('link[0][uri]', '/');
$page
->pressButton('Save');
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display');
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$assert_session
->linkExists('Manage layout');
$this
->clickLink('Manage layout');
$assert_session
->linkExists('Add section');
$this
->clickLink('Add section');
$assert_session
->linkExists('Layout plugin (with dependencies)');
$this
->clickLink('Layout plugin (with dependencies)');
$page
->pressButton('Add section');
$assert_session
->elementExists('css', '.layout--layout-test-dependencies-plugin');
$assert_session
->elementExists('css', '.field--name-body');
$page
->pressButton('Save layout');
$this
->drupalGet('admin/structure/menu/manage/my-other-menu/delete');
$this
->submitForm([], 'Delete');
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default/layout');
$assert_session
->elementNotExists('css', '.layout--layout-test-dependencies-plugin');
$assert_session
->elementExists('css', '.field--name-body');
// Add a menu block.
$assert_session
->linkExists('Add block');
$this
->clickLink('Add block');
$assert_session
->linkExists('My Menu');
$this
->clickLink('My Menu');
$page
->pressButton('Add block');
// Add another block alongside the menu.
$assert_session
->linkExists('Add block');
$this
->clickLink('Add block');
$assert_session
->linkExists('Powered by Drupal');
$this
->clickLink('Powered by Drupal');
$page
->pressButton('Add block');
// Assert that the blocks are visible, and save the layout.
$assert_session
->pageTextContains('Powered by Drupal');
$assert_session
->pageTextContains('My Menu');
$assert_session
->elementExists('css', '.block.menu--my-menu');
$page
->pressButton('Save layout');
// Delete the menu.
$this
->drupalGet('admin/structure/menu/manage/my-menu/delete');
$this
->submitForm([], 'Delete');
// Ensure that the menu block is gone, but that the other block remains.
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default/layout');
$assert_session
->pageTextContains('Powered by Drupal');
$assert_session
->pageTextNotContains('My Menu');
$assert_session
->elementNotExists('css', '.block.menu--my-menu');
}
/**
* Tests the interaction between full and default view modes.
*
* @see \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::getDefaultSectionStorage()
*/
public function testLayoutBuilderUiFullViewMode() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'administer node fields',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// For the purposes of this test, turn the full view mode on and off to
// prevent copying from the customized default view mode.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'display_modes_custom[full]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'display_modes_custom[full]' => FALSE,
], 'Save');
// Allow overrides for the layout.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
// Customize the default view mode.
$this
->drupalGet("{$field_ui_prefix}/display/default/layout");
$this
->clickLink('Add block');
$this
->clickLink('Powered by Drupal');
$page
->fillField('settings[label]', 'This is the default view mode');
$page
->checkField('settings[label_display]');
$page
->pressButton('Add block');
$assert_session
->pageTextContains('This is the default view mode');
$page
->pressButton('Save layout');
// The default view mode is used for both the node display and layout UI.
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('This is the default view mode');
$assert_session
->pageTextNotContains('This is the full view mode');
$this
->drupalGet('node/1/layout');
$assert_session
->pageTextContains('This is the default view mode');
$assert_session
->pageTextNotContains('This is the full view mode');
$page
->pressButton('Discard changes');
$page
->pressButton('Confirm');
// Enable the full view mode and customize it.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'display_modes_custom[full]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/full");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/full");
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/full/layout");
$this
->clickLink('Add block');
$this
->clickLink('Powered by Drupal');
$page
->fillField('settings[label]', 'This is the full view mode');
$page
->checkField('settings[label_display]');
$page
->pressButton('Add block');
$assert_session
->pageTextContains('This is the full view mode');
$page
->pressButton('Save layout');
// The full view mode is now used for both the node display and layout UI.
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
$this
->drupalGet('node/1/layout');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
$page
->pressButton('Discard changes');
$page
->pressButton('Confirm');
// Disable the full view mode, the default should be used again.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'display_modes_custom[full]' => FALSE,
], 'Save');
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('This is the default view mode');
$assert_session
->pageTextNotContains('This is the full view mode');
$this
->drupalGet('node/1/layout');
$assert_session
->pageTextContains('This is the default view mode');
$assert_session
->pageTextNotContains('This is the full view mode');
$page
->pressButton('Discard changes');
$page
->pressButton('Confirm');
// Re-enabling the full view mode restores the layout changes.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'display_modes_custom[full]' => TRUE,
], 'Save');
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
$this
->drupalGet('node/1/layout');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
// Create an override of the full view mode.
$this
->clickLink('Add block');
$this
->clickLink('Powered by Drupal');
$page
->fillField('settings[label]', 'This is an override of the full view mode');
$page
->checkField('settings[label_display]');
$page
->pressButton('Add block');
$assert_session
->pageTextContains('This is an override of the full view mode');
$page
->pressButton('Save layout');
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextContains('This is an override of the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
$this
->drupalGet('node/1/layout');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextContains('This is an override of the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
$page
->pressButton('Discard changes');
$page
->pressButton('Confirm');
// The override does not affect the full view mode.
$this
->drupalGet("{$field_ui_prefix}/display/full/layout");
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextNotContains('This is an override of the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
// Reverting the override restores back to the full view mode.
$this
->drupalGet('node/1/layout');
$page
->pressButton('Revert to default');
$page
->pressButton('Revert');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextNotContains('This is an override of the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
$this
->drupalGet('node/1/layout');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextNotContains('This is an override of the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
// Recreate an override of the full view mode.
$this
->clickLink('Add block');
$this
->clickLink('Powered by Drupal');
$page
->fillField('settings[label]', 'This is an override of the full view mode');
$page
->checkField('settings[label_display]');
$page
->pressButton('Add block');
$assert_session
->pageTextContains('This is an override of the full view mode');
$page
->pressButton('Save layout');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextContains('This is an override of the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
$this
->drupalGet('node/1/layout');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextContains('This is an override of the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
$page
->pressButton('Discard changes');
$page
->pressButton('Confirm');
// Disable the full view mode.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'display_modes_custom[full]' => FALSE,
], 'Save');
// The override of the full view mode is still available.
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('This is the full view mode');
$assert_session
->pageTextContains('This is an override of the full view mode');
$assert_session
->pageTextNotContains('This is the default view mode');
// Reverting the override restores back to the default view mode.
$this
->drupalGet('node/1/layout');
$page
->pressButton('Revert to default');
$page
->pressButton('Revert');
$assert_session
->pageTextContains('This is the default view mode');
$assert_session
->pageTextNotContains('This is the full view mode');
$this
->drupalGet('node/1/layout');
$assert_session
->pageTextContains('This is the default view mode');
$assert_session
->pageTextNotContains('This is the full view mode');
$page
->pressButton('Discard changes');
$page
->pressButton('Confirm');
}
/**
* Ensures that one bundle doesn't interfere with another bundle.
*/
public function testFullViewModeMultipleBundles() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
// Create one bundle with the full view mode enabled.
$this
->createContentType([
'type' => 'full_bundle',
]);
$this
->drupalGet('admin/structure/types/manage/full_bundle/display/default');
$page
->checkField('display_modes_custom[full]');
$page
->pressButton('Save');
// Create another bundle without the full view mode enabled.
$this
->createContentType([
'type' => 'default_bundle',
]);
$this
->drupalGet('admin/structure/types/manage/default_bundle/display/default');
// Enable Layout Builder for defaults and overrides.
$page
->checkField('layout[enabled]');
$page
->pressButton('Save');
$page
->checkField('layout[allow_custom]');
$page
->pressButton('Save');
$assert_session
->checkboxChecked('layout[allow_custom]');
}
/**
* {@inheritdoc}
*/
public function testLayoutBuilderChooseBlocksAlter() {
// See layout_builder_test_plugin_filter_block__layout_builder_alter().
$assert_session = $this
->assertSession();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'administer node fields',
]));
// From the manage display page, go to manage the layout.
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$assert_session
->linkExists('Manage layout');
$this
->clickLink('Manage layout');
// Add a new block.
$this
->clickLink('Add block');
// Verify that blocks not modified are present.
$assert_session
->linkExists('Powered by Drupal');
$assert_session
->linkExists('Default revision');
// Verify that blocks explicitly removed are not present.
$assert_session
->linkNotExists('Help');
$assert_session
->linkNotExists('Sticky at top of lists');
$assert_session
->linkNotExists('Main page content');
$assert_session
->linkNotExists('Page title');
// Verify that Changed block is not present on first section.
$assert_session
->linkNotExists('Changed');
// Go back to Manage layout.
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$this
->clickLink('Manage layout');
// Add a new section.
$this
->clickLink('Add section', 1);
$assert_session
->linkExists('Two column');
$this
->clickLink('Two column');
$assert_session
->buttonExists('Add section');
$this
->getSession()
->getPage()
->pressButton('Add section');
// Add a new block to second section.
$this
->clickLink('Add block', 1);
// Verify that Changed block is present on second section.
$assert_session
->linkExists('Changed');
}
/**
* Tests that extra fields work before and after enabling Layout Builder.
*/
public function testExtraFields() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$this
->drupalGet('node');
$assert_session
->linkExists('Read more');
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
// Extra fields display under "Content fields".
$this
->drupalGet("admin/structure/types/manage/bundle_with_section_field/display/default/layout");
$this
->clickLink('Add block');
$assert_session
->elementTextContains('xpath', '//details/summary[contains(text(),"Content fields")]/parent::details', 'Extra label');
$this
->drupalGet('node');
$assert_session
->linkExists('Read more');
// Consider an extra field hidden by default. Make sure it's not displayed.
$this
->drupalGet('node/1');
$assert_session
->pageTextNotContains('Extra Field 2 is hidden by default.');
// View the layout and add the extra field that is not visible by default.
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default/layout');
$assert_session
->pageTextNotContains('Extra Field 2');
$page = $this
->getSession()
->getPage();
$page
->clickLink('Add block');
$page
->clickLink('Extra Field 2');
$page
->pressButton('Add block');
$assert_session
->pageTextContains('Extra Field 2');
$page
->pressButton('Save layout');
// Confirm that the newly added extra field is visible.
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('Extra Field 2 is hidden by default.');
}
/**
* Tests loading a pending revision in the Layout Builder UI.
*/
public function testPendingRevision() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// Enable overrides.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$storage = $this->container
->get('entity_type.manager')
->getStorage('node');
$node = $storage
->load(1);
// Create a pending revision.
$pending_revision = $storage
->createRevision($node, FALSE);
$pending_revision
->set('title', 'The pending title of the first node');
$pending_revision
->save();
// The original node title is available when viewing the node, but the
// pending title is visible within the Layout Builder UI.
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('The first node title');
$page
->clickLink('Layout');
$assert_session
->pageTextNotContains('The first node title');
$assert_session
->pageTextContains('The pending title of the first node');
}
/**
* Tests that deleting a View block used in Layout Builder works.
*/
public function testDeletedView() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// Enable overrides.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$this
->drupalGet('node/1');
$assert_session
->linkExists('Layout');
$this
->clickLink('Layout');
$this
->clickLink('Add block');
$this
->clickLink('Test Block View');
$page
->pressButton('Add block');
$assert_session
->pageTextContains('Test Block View');
$assert_session
->elementExists('css', '.block-views-blocktest-block-view-block-1');
$page
->pressButton('Save');
$assert_session
->pageTextContains('Test Block View');
$assert_session
->elementExists('css', '.block-views-blocktest-block-view-block-1');
View::load('test_block_view')
->delete();
$this
->drupalGet('node/1');
// Node can be loaded after deleting the View.
$assert_session
->pageTextContains(Node::load(1)
->getTitle());
$assert_session
->pageTextNotContains('Test Block View');
}
/**
* Tests that hook_form_alter() has access to the Layout Builder info.
*/
public function testFormAlter() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'administer node fields',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
$this
->drupalGet("{$field_ui_prefix}/display/default");
$page
->checkField('layout[enabled]');
$page
->pressButton('Save');
$page
->clickLink('Manage layout');
$page
->clickLink('Add block');
$page
->clickLink('Powered by Drupal');
$assert_session
->pageTextContains('Layout Builder Storage: node.bundle_with_section_field.default');
$assert_session
->pageTextContains('Layout Builder Section: layout_onecol');
$assert_session
->pageTextContains('Layout Builder Component: system_powered_by_block');
}
/**
* Tests the functionality of custom section labels.
*/
public function testSectionLabels() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$page
->checkField('layout[enabled]');
$page
->pressButton('Save');
$page
->checkField('layout[allow_custom]');
$page
->pressButton('Save');
$this
->drupalGet('node/1/layout');
$page
->clickLink('Add section');
$page
->clickLink('One column');
$page
->fillField('layout_settings[label]', 'My Cool Section');
$page
->pressButton('Add section');
$assert_session
->pageTextContains('My Cool Section');
$page
->pressButton('Save layout');
$assert_session
->pageTextNotContains('My Cool Section');
}
/**
* Tests that layouts can be context-aware.
*/
public function testContextAwareLayouts() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$account = $this
->drupalCreateUser([
'configure any layout',
'administer node display',
]);
$this
->drupalLogin($account);
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$page
->clickLink('Manage layout');
$page
->clickLink('Add section');
$page
->clickLink('Layout Builder Test: Context Aware');
$page
->pressButton('Add section');
// See \Drupal\layout_builder_test\Plugin\Layout\TestContextAwareLayout::build().
$assert_session
->elementExists('css', '.user--' . $account
->getAccountName());
$page
->clickLink('Configure Section 1');
$page
->fillField('layout_settings[label]', 'My section');
$page
->pressButton('Update');
$assert_session
->linkExists('Configure My section');
$page
->clickLink('Add block');
$page
->clickLink('Powered by Drupal');
$page
->pressButton('Add block');
$page
->pressButton('Save layout');
$this
->drupalGet('node/1');
// See \Drupal\layout_builder_test\Plugin\Layout\TestContextAwareLayout::build().
$assert_session
->elementExists('css', '.user--' . $account
->getAccountName());
}
/**
* Tests that sections can provide custom attributes.
*/
public function testCustomSectionAttributes() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$page
->clickLink('Manage layout');
$page
->clickLink('Add section');
$page
->clickLink('Layout Builder Test Plugin');
$page
->pressButton('Add section');
// See \Drupal\layout_builder_test\Plugin\Layout\LayoutBuilderTestPlugin::build().
$assert_session
->elementExists('css', '.go-birds');
}
/**
* Tests the usage of placeholders for empty blocks.
*
* @see \Drupal\Core\Block\BlockPluginInterface::getPlaceholderString()
* @see \Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray::onBuildRender()
*/
public function testBlockPlaceholder() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
// Customize the default view mode.
$this
->drupalGet("{$field_ui_prefix}/display/default/layout");
// Add a block whose content is controlled by state and is empty by default.
$this
->clickLink('Add block');
$this
->clickLink('Test block caching');
$page
->fillField('settings[label]', 'The block label');
$page
->pressButton('Add block');
$block_content = 'I am content';
$placeholder_content = 'Placeholder for the "The block label" block';
// The block placeholder is displayed and there is no content.
$assert_session
->pageTextContains($placeholder_content);
$assert_session
->pageTextNotContains($block_content);
// Set block content and reload the page.
\Drupal::state()
->set('block_test.content', $block_content);
$this
->getSession()
->reload();
// The block placeholder is no longer displayed and the content is visible.
$assert_session
->pageTextNotContains($placeholder_content);
$assert_session
->pageTextContains($block_content);
}
/**
* Tests a custom alter of the overrides form.
*/
public function testOverridesFormAlter() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'administer nodes',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// Enable overrides.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$this
->drupalGet('node/1');
// The status checkbox should be checked by default.
$page
->clickLink('Layout');
$assert_session
->checkboxChecked('status[value]');
$page
->pressButton('Save layout');
$assert_session
->pageTextContains('The layout override has been saved.');
// Unchecking the status checkbox will unpublish the entity.
$page
->clickLink('Layout');
$page
->uncheckField('status[value]');
$page
->pressButton('Save layout');
$assert_session
->statusCodeEquals(403);
$assert_session
->pageTextContains('The layout override has been saved.');
}
/**
* Tests the Block UI when Layout Builder is installed.
*/
public function testBlockUiListing() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'administer blocks',
]));
$this
->drupalGet('admin/structure/block');
$page
->clickLink('Place block');
// Ensure that blocks expected to appear are available.
$assert_session
->pageTextContains('Test HTML block');
$assert_session
->pageTextContains('Block test');
// Ensure that blocks not expected to appear are not available.
$assert_session
->pageTextNotContains('Body');
$assert_session
->pageTextNotContains('Content fields');
}
/**
* Tests the expected breadcrumbs of the Layout Builder UI.
*/
public function testBreadcrumb() {
$page = $this
->getSession()
->getPage();
$this
->drupalPlaceBlock('system_breadcrumb_block');
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'administer content types',
'access administration pages',
]));
// From the manage display page, go to manage the layout.
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$page
->clickLink('Manage layout');
$breadcrumb_titles = [];
foreach ($page
->findAll('css', '.breadcrumb a') as $link) {
$breadcrumb_titles[$link
->getText()] = $link
->getAttribute('href');
}
$base_path = base_path();
$expected = [
'Home' => $base_path,
'Administration' => $base_path . 'admin',
'Structure' => $base_path . 'admin/structure',
'Content types' => $base_path . 'admin/structure/types',
'Bundle with section field' => $base_path . 'admin/structure/types/manage/bundle_with_section_field',
'Manage display' => $base_path . 'admin/structure/types/manage/bundle_with_section_field/display/default',
'External link' => 'http://www.example.com',
];
$this
->assertSame($expected, $breadcrumb_titles);
}
/**
* Tests a config-based implementation of Layout Builder.
*
* @see \Drupal\layout_builder_test\Plugin\SectionStorage\SimpleConfigSectionStorage
*/
public function testSimpleConfigBasedLayout() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this
->createUser([
'configure any layout',
]));
// Prepare an object with a pre-existing section.
$this->container
->get('config.factory')
->getEditable('layout_builder_test.test_simple_config.existing')
->set('sections', [
(new Section('layout_twocol'))
->toArray(),
])
->save();
// The pre-existing section is found.
$this
->drupalGet('layout-builder-test-simple-config/existing');
$assert_session
->elementsCount('css', '.layout', 1);
$assert_session
->elementsCount('css', '.layout--twocol', 1);
// No layout is selected for a new object.
$this
->drupalGet('layout-builder-test-simple-config/new');
$assert_session
->elementNotExists('css', '.layout');
}
/**
* Tests removing all sections from overrides and defaults.
*/
public function testRemovingAllSections() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
// Install Quick Edit as well.
$this->container
->get('module_installer')
->install([
'quickedit',
]);
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'access in-place editing',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// Enable overrides.
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
// By default, there is one section.
$this
->drupalGet('node/1');
$assert_session
->elementsCount('css', '.layout', 1);
$assert_session
->pageTextContains('The first node body');
$page
->clickLink('Layout');
$assert_session
->elementsCount('css', '.layout', 1);
$assert_session
->elementsCount('css', '.layout-builder__add-block', 1);
$assert_session
->elementsCount('css', '.layout-builder__add-section', 2);
// Remove the only section from the override.
$page
->clickLink('Remove Section 1');
$page
->pressButton('Remove');
$assert_session
->elementsCount('css', '.layout', 0);
$assert_session
->elementsCount('css', '.layout-builder__add-block', 0);
$assert_session
->elementsCount('css', '.layout-builder__add-section', 1);
// The override is still used instead of the default, despite being empty.
$page
->pressButton('Save layout');
$assert_session
->elementsCount('css', '.layout', 0);
$assert_session
->pageTextNotContains('The first node body');
$page
->clickLink('Layout');
$assert_session
->elementsCount('css', '.layout', 0);
$assert_session
->elementsCount('css', '.layout-builder__add-block', 0);
$assert_session
->elementsCount('css', '.layout-builder__add-section', 1);
// Add one section to the override.
$page
->clickLink('Add section');
$page
->clickLink('One column');
$page
->pressButton('Add section');
$assert_session
->elementsCount('css', '.layout', 1);
$assert_session
->elementsCount('css', '.layout-builder__add-block', 1);
$assert_session
->elementsCount('css', '.layout-builder__add-section', 2);
$page
->pressButton('Save layout');
$assert_session
->elementsCount('css', '.layout', 1);
$assert_session
->pageTextNotContains('The first node body');
// By default, the default has one section.
$this
->drupalGet("{$field_ui_prefix}/display/default/layout");
$assert_session
->elementsCount('css', '.layout', 1);
$assert_session
->elementsCount('css', '.layout-builder__add-block', 1);
$assert_session
->elementsCount('css', '.layout-builder__add-section', 2);
// Remove the only section from the default.
$page
->clickLink('Remove Section 1');
$page
->pressButton('Remove');
$assert_session
->elementsCount('css', '.layout', 0);
$assert_session
->elementsCount('css', '.layout-builder__add-block', 0);
$assert_session
->elementsCount('css', '.layout-builder__add-section', 1);
$page
->pressButton('Save layout');
$page
->clickLink('Manage layout');
$assert_session
->elementsCount('css', '.layout', 0);
$assert_session
->elementsCount('css', '.layout-builder__add-block', 0);
$assert_session
->elementsCount('css', '.layout-builder__add-section', 1);
// The override is still in use.
$this
->drupalGet('node/1');
$assert_session
->elementsCount('css', '.layout', 1);
$assert_session
->pageTextNotContains('The first node body');
$page
->clickLink('Layout');
$assert_session
->elementsCount('css', '.layout', 1);
$assert_session
->elementsCount('css', '.layout-builder__add-block', 1);
$assert_session
->elementsCount('css', '.layout-builder__add-section', 2);
// Revert the override.
$page
->pressButton('Revert to defaults');
$page
->pressButton('Revert');
$assert_session
->elementsCount('css', '.layout', 0);
$assert_session
->pageTextNotContains('The first node body');
}
/**
* Tests removing section without layout label configuration.
*/
public function testRemovingSectionWithoutLayoutLabel() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
// Enable overrides.
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/default/layout");
$page
->clickLink('Add section');
$assert_session
->linkExists('Layout Without Label');
$page
->clickLink('Layout Without Label');
$page
->pressButton('Add section');
$assert_session
->elementsCount('css', '.layout', 2);
$assert_session
->linkExists('Remove Section 1');
$this
->clickLink('Remove Section 1');
$page
->pressButton('Remove');
$assert_session
->statusCodeEquals(200);
$assert_session
->elementsCount('css', '.layout', 1);
}
/**
* Asserts that the correct layouts are available.
*/
protected function assertCorrectLayouts() {
$assert_session = $this
->assertSession();
// Ensure the layouts provided by layout_builder are available.
$expected_layouts_hrefs = [
'layout_builder/configure/section/overrides/node.1/0/layout_onecol',
'layout_builder/configure/section/overrides/node.1/0/layout_twocol_section',
'layout_builder/configure/section/overrides/node.1/0/layout_threecol_section',
'layout_builder/configure/section/overrides/node.1/0/layout_fourcol_section',
];
foreach ($expected_layouts_hrefs as $expected_layouts_href) {
$assert_session
->linkByHrefExists($expected_layouts_href);
}
// Ensure the layout_discovery module's layouts were removed.
$unexpected_layouts = [
'twocol',
'twocol_bricks',
'threecol_25_50_25',
'threecol_33_34_33',
];
foreach ($unexpected_layouts as $unexpected_layout) {
$assert_session
->linkByHrefNotExists("layout_builder/add/section/overrides/node.1/0/{$unexpected_layout}");
$assert_session
->linkByHrefNotExists("layout_builder/configure/section/overrides/node.1/0/{$unexpected_layout}");
}
}
/**
* Tests the Layout Builder UI with a context defined at runtime.
*/
public function testLayoutBuilderContexts() {
$node_url = 'node/1';
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$this
->drupalGet($node_url);
$assert_session
->linkExists('Layout');
$this
->clickLink('Layout');
$assert_session
->linkExists('Add section');
// Add the testing block.
$page
->clickLink('Add block');
$this
->clickLink('Can I have runtime contexts');
$page
->pressButton('Add block');
// Ensure the runtime context value is rendered before saving.
$assert_session
->pageTextContains('for sure you can');
// Save the layout, and test that the value is rendered after save.
$page
->pressButton('Save layout');
$assert_session
->addressEquals($node_url);
$assert_session
->pageTextContains('for sure you can');
$assert_session
->elementExists('css', '.layout');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | Asserts whether an expected cache tag was present in the last response. | |
AssertLegacyTrait:: |
protected | function | Asserts that the element with the given CSS selector is not present. | |
AssertLegacyTrait:: |
protected | function | Asserts that the element with the given CSS selector is present. | |
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertLegacyTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertLegacyTrait:: |
protected | function | Checks that current response header equals value. | |
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertLegacyTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertLegacyTrait:: |
protected | function | Asserts whether an expected cache tag was absent in the last response. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text is not found escaped on the loaded page. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does NOT exist with the given name or ID. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertLegacyTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertLegacyTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertLegacyTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option does NOT exist in the current page. | |
AssertLegacyTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is not found in the raw content. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS not found on the loaded page, fail otherwise. | |
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | |
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertLegacyTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | |
AssertLegacyTrait:: |
protected | function | Asserts the page responds with the specified response code. | |
AssertLegacyTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | |
AssertLegacyTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertLegacyTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertLegacyTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertLegacyTrait:: |
protected | function | Passes if the internal browser's URL matches the given path. | |
AssertLegacyTrait:: |
protected | function | Builds an XPath query. | |
AssertLegacyTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertLegacyTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertLegacyTrait:: |
protected | function | Gets the current raw content. | |
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | ||
BlockCreationTrait:: |
protected | function | Creates a block instance based on default settings. Aliased as: drupalPlaceBlock | |
BrowserHtmlDebugTrait:: |
protected | property | The Base URI to use for links to the output files. | |
BrowserHtmlDebugTrait:: |
protected | property | Class name for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Counter for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Counter storage for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Directory name for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | HTML output output enabled. | |
BrowserHtmlDebugTrait:: |
protected | property | The file name to write the list of URLs to. | |
BrowserHtmlDebugTrait:: |
protected | property | HTML output test ID. | |
BrowserHtmlDebugTrait:: |
protected | function | Formats HTTP headers as string for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | function | Returns headers in HTML output format. | 1 |
BrowserHtmlDebugTrait:: |
protected | function | Provides a Guzzle middleware handler to log every response received. | |
BrowserHtmlDebugTrait:: |
protected | function | Logs a HTML output message in a text file. | |
BrowserHtmlDebugTrait:: |
protected | function | Creates the directory to store browser output. | |
BrowserTestBase:: |
protected | property | The base URL. | |
BrowserTestBase:: |
protected | property | The config importer that can be used in a test. | |
BrowserTestBase:: |
protected | property | An array of custom translations suitable for drupal_rewrite_settings(). | |
BrowserTestBase:: |
protected | property | The database prefix of this test run. | |
BrowserTestBase:: |
protected | property | Mink session manager. | |
BrowserTestBase:: |
protected | property | Mink default driver params. | |
BrowserTestBase:: |
protected | property | Mink class for the default driver to use. | 1 |
BrowserTestBase:: |
protected | property | The original container. | |
BrowserTestBase:: |
protected | property | The original array of shutdown function callbacks. | |
BrowserTestBase:: |
protected | property | ||
BrowserTestBase:: |
protected | property | The profile to install as a basis for testing. | 39 |
BrowserTestBase:: |
protected | property | The app root. | |
BrowserTestBase:: |
protected | property | Browser tests are run in separate processes to prevent collisions between code that may be loaded by tests. | |
BrowserTestBase:: |
protected | property | Time limit in seconds for the test. | |
BrowserTestBase:: |
protected | property | The translation file directory for the test environment. | |
BrowserTestBase:: |
protected | function | Clean up the Simpletest environment. | |
BrowserTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
BrowserTestBase:: |
protected | function | Gets the value of an HTTP response header. | |
BrowserTestBase:: |
public static | function | Ensures test files are deletable. | |
BrowserTestBase:: |
protected | function | Gets an instance of the default Mink driver. | |
BrowserTestBase:: |
protected | function | Gets the JavaScript drupalSettings variable for the currently-loaded page. | 1 |
BrowserTestBase:: |
protected | function | Obtain the HTTP client for the system under test. | |
BrowserTestBase:: |
protected | function | Get the Mink driver args from an environment variable, if it is set. Can be overridden in a derived class so it is possible to use a different value for a subset of tests, e.g. the JavaScript tests. | 1 |
BrowserTestBase:: |
protected | function | Helper function to get the options of select field. | |
BrowserTestBase:: |
public | function | Returns Mink session. | |
BrowserTestBase:: |
protected | function | Get session cookies from current session. | |
BrowserTestBase:: |
protected | function |
Retrieves the current calling line in the class under test. Overrides BrowserHtmlDebugTrait:: |
|
BrowserTestBase:: |
protected | function | Visits the front page when initializing Mink. | 3 |
BrowserTestBase:: |
protected | function | Initializes Mink sessions. | 1 |
BrowserTestBase:: |
public | function | Installs Drupal into the Simpletest site. | 1 |
BrowserTestBase:: |
protected | function | Registers additional Mink sessions. | |
BrowserTestBase:: |
protected | function | Sets up the root application path. | |
BrowserTestBase:: |
public static | function | 1 | |
BrowserTestBase:: |
protected | function | 3 | |
BrowserTestBase:: |
protected | function | Transforms a nested array into a flat array suitable for submitForm(). | |
BrowserTestBase:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
BrowserTestBase:: |
public | function | Prevents serializing any properties. | |
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
ContentTypeCreationTrait:: |
protected | function | Creates a custom content type based on default settings. Aliased as: drupalCreateContentType | 1 |
ExtensionListTestTrait:: |
protected | function | Gets the path for the specified module. | |
ExtensionListTestTrait:: |
protected | function | Gets the path for the specified theme. | |
FunctionalTestSetupTrait:: |
protected | property | The flag to set 'apcu_ensure_unique_prefix' setting. | 1 |
FunctionalTestSetupTrait:: |
protected | property | The class loader to use for installation and initialization of setup. | |
FunctionalTestSetupTrait:: |
protected | property | The "#1" admin user. | |
FunctionalTestSetupTrait:: |
protected | function | Execute the non-interactive installer. | 1 |
FunctionalTestSetupTrait:: |
protected | function | Returns all supported database driver installer objects. | |
FunctionalTestSetupTrait:: |
protected | function | Initialize various configurations post-installation. | 1 |
FunctionalTestSetupTrait:: |
protected | function | Initializes the kernel after installation. | |
FunctionalTestSetupTrait:: |
protected | function | Initialize settings created during install. | |
FunctionalTestSetupTrait:: |
protected | function | Initializes user 1 for the site to be installed. | |
FunctionalTestSetupTrait:: |
protected | function | Installs the default theme defined by `static::$defaultTheme` when needed. | |
FunctionalTestSetupTrait:: |
protected | function | Install modules defined by `static::$modules`. | 1 |
FunctionalTestSetupTrait:: |
protected | function | Returns the parameters that will be used when Simpletest installs Drupal. | 9 |
FunctionalTestSetupTrait:: |
protected | function | Prepares the current environment for running the test. | 20 |
FunctionalTestSetupTrait:: |
protected | function | Creates a mock request and sets it on the generator. | |
FunctionalTestSetupTrait:: |
protected | function | Prepares site settings and services before installation. | 2 |
FunctionalTestSetupTrait:: |
protected | function | Resets and rebuilds the environment after setup. | |
FunctionalTestSetupTrait:: |
protected | function | Rebuilds \Drupal::getContainer(). | |
FunctionalTestSetupTrait:: |
protected | function | Resets all data structures after having enabled new modules. | |
FunctionalTestSetupTrait:: |
protected | function | Changes parameters in the services.yml file. | |
FunctionalTestSetupTrait:: |
protected | function | Sets up the base URL based upon the environment variable. | |
FunctionalTestSetupTrait:: |
protected | function | Rewrites the settings.php file of the test site. | 1 |
LayoutBuilderTest:: |
protected | property |
The theme to install as the default for testing. Overrides BrowserTestBase:: |
|
LayoutBuilderTest:: |
protected static | property |
Modules to enable. Overrides BrowserTestBase:: |
|
LayoutBuilderTest:: |
protected | function | Asserts that the correct layouts are available. | |
LayoutBuilderTest:: |
protected | function |
Overrides BrowserTestBase:: |
|
LayoutBuilderTest:: |
public | function | Tests that layout builder checks entity view access. | |
LayoutBuilderTest:: |
public | function | Tests the usage of placeholders for empty blocks. | |
LayoutBuilderTest:: |
public | function | Tests the Block UI when Layout Builder is installed. | |
LayoutBuilderTest:: |
public | function | Tests the expected breadcrumbs of the Layout Builder UI. | |
LayoutBuilderTest:: |
public | function | Tests that layouts can be context-aware. | |
LayoutBuilderTest:: |
public | function | Tests that sections can provide custom attributes. | |
LayoutBuilderTest:: |
public | function | Tests that deleting a View block used in Layout Builder works. | |
LayoutBuilderTest:: |
public | function | Tests deleting a field in-use by an overridden layout. | |
LayoutBuilderTest:: |
public | function | Tests that extra fields work before and after enabling Layout Builder. | |
LayoutBuilderTest:: |
public | function | Tests that hook_form_alter() has access to the Layout Builder info. | |
LayoutBuilderTest:: |
public | function | Ensures that one bundle doesn't interfere with another bundle. | |
LayoutBuilderTest:: |
public | function | Test decorating controller.entity_form while layout_builder is installed. | |
LayoutBuilderTest:: |
public | function | ||
LayoutBuilderTest:: |
public | function | Tests the Layout Builder UI with a context defined at runtime. | |
LayoutBuilderTest:: |
public | function | ||
LayoutBuilderTest:: |
public | function | Tests the interaction between full and default view modes. | |
LayoutBuilderTest:: |
public | function | Tests the Layout Builder UI for an entity type without a bundle. | |
LayoutBuilderTest:: |
public | function | Tests that a non-default view mode works as expected. | |
LayoutBuilderTest:: |
public | function | Tests functionality of Layout Builder for overrides. | |
LayoutBuilderTest:: |
public | function | Tests a custom alter of the overrides form. | |
LayoutBuilderTest:: |
public | function | Tests Layout Builder overrides without access to edit the default layout. | |
LayoutBuilderTest:: |
public | function | Tests loading a pending revision in the Layout Builder UI. | |
LayoutBuilderTest:: |
public | function | Tests that component's dependencies are respected during removal. | |
LayoutBuilderTest:: |
public | function | Tests that the Layout Builder preserves entity values. | |
LayoutBuilderTest:: |
public | function | Tests removing all sections from overrides and defaults. | |
LayoutBuilderTest:: |
public | function | Tests removing section without layout label configuration. | |
LayoutBuilderTest:: |
public | function | Tests the functionality of custom section labels. | |
LayoutBuilderTest:: |
public | function | Tests a config-based implementation of Layout Builder. | |
NodeCreationTrait:: |
protected | function | Creates a node based on default settings. Aliased as: drupalCreateNode | |
NodeCreationTrait:: |
public | function | Get a node from the database based on its title. Aliased as: drupalGetNodeByTitle | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | 1 |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
RefreshVariablesTrait:: |
protected | function | Refreshes in-memory configuration and state information. | 1 |
SessionTestTrait:: |
protected | property | The name of the session cookie. | |
SessionTestTrait:: |
protected | function | Generates a session cookie name. | |
SessionTestTrait:: |
protected | function | Returns the session name in use on the child site. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | 1 |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. | |
TestSetupTrait:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
TestSetupTrait:: |
protected | property | The dependency injection container used in the test. | |
TestSetupTrait:: |
protected | property | The DrupalKernel instance used in the test. | |
TestSetupTrait:: |
protected | property | The site directory of the original parent site. | |
TestSetupTrait:: |
protected | property | The private file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The public file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The site directory of this test run. | |
TestSetupTrait:: |
protected | property | Set to TRUE to strict check all configuration saved. | 1 |
TestSetupTrait:: |
protected | property | The temporary file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The test run ID. | |
TestSetupTrait:: |
protected | function | Changes the database connection to the prefixed one. | |
TestSetupTrait:: |
protected | function | Gets the config schema exclusions for this test. | |
TestSetupTrait:: |
public static | function | Returns the database connection to the site running Simpletest. | |
TestSetupTrait:: |
protected | function | Generates a database prefix for running tests. | 1 |
UiHelperTrait:: |
protected | property | The current user logged in using the Mink controlled browser. | |
UiHelperTrait:: |
protected | property | The number of meta refresh redirects to follow, or NULL if unlimited. | |
UiHelperTrait:: |
protected | property | The number of meta refresh redirects followed during ::drupalGet(). | |
UiHelperTrait:: |
public | function | Returns WebAssert object. | 1 |
UiHelperTrait:: |
protected | function | Builds an absolute URL from a system path or a URL object. | |
UiHelperTrait:: |
protected | function | Checks for meta refresh tag and if found call drupalGet() recursively. | |
UiHelperTrait:: |
protected | function | Clicks the element with the given CSS selector. | |
UiHelperTrait:: |
protected | function | Follows a link by complete name. | |
UiHelperTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
UiHelperTrait:: |
protected | function | Translates a CSS expression to its XPath equivalent. | |
UiHelperTrait:: |
protected | function | Retrieves a Drupal path or an absolute path. | 2 |
UiHelperTrait:: |
protected | function | Logs in a user using the Mink controlled browser. | |
UiHelperTrait:: |
protected | function | Logs a user out of the Mink controlled browser and confirms. | |
UiHelperTrait:: |
protected | function | Executes a form submission. | |
UiHelperTrait:: |
protected | function | Returns whether a given user account is logged in. | |
UiHelperTrait:: |
protected | function | Takes a path and returns an absolute path. | |
UiHelperTrait:: |
protected | function | Retrieves the plain-text content from the current page. | |
UiHelperTrait:: |
protected | function | Get the current URL from the browser. | |
UiHelperTrait:: |
protected | function | Determines if test is using DrupalTestBrowser. | |
UiHelperTrait:: |
protected | function | Prepare for a request to testing site. | 1 |
UiHelperTrait:: |
protected | function | Fills and submits a form. | |
UserCreationTrait:: |
protected | function | Checks whether a given list of permission names is valid. | |
UserCreationTrait:: |
protected | function | Creates an administrative role. | |
UserCreationTrait:: |
protected | function | Creates a role with specified permissions. Aliased as: drupalCreateRole | |
UserCreationTrait:: |
protected | function | Create a user with a given set of permissions. Aliased as: drupalCreateUser | |
UserCreationTrait:: |
protected | function | Grant permissions to a user role. | |
UserCreationTrait:: |
protected | function | Switch the current logged in user. | |
UserCreationTrait:: |
protected | function | Creates a random user account and sets it as current user. | |
XdebugRequestTrait:: |
protected | function | Adds xdebug cookies, from request setup. |