public function LayoutRestTestBase::setUp in Layout Builder Symmetric Translations 8
Overrides ResourceTestBase::setUp
1 call to LayoutRestTestBase::setUp()
- OverrideSectionsTest::setUp in tests/
src/ Functional/ Rest/ OverrideSectionsTest.php
1 method overrides LayoutRestTestBase::setUp()
- OverrideSectionsTest::setUp in tests/
src/ Functional/ Rest/ OverrideSectionsTest.php
File
- tests/
src/ Functional/ Rest/ LayoutRestTestBase.php, line 46
Class
- LayoutRestTestBase
- Base class for Layout Builder REST tests.
Namespace
Drupal\Tests\layout_builder_st\Functional\RestCode
public function setUp() {
parent::setUp();
$assert_session = $this
->assertSession();
$this
->createContentType([
'type' => 'bundle_with_section_field',
]);
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'administer display modes',
'bypass node access',
'create bundle_with_section_field content',
'edit any bundle_with_section_field content',
]));
$page = $this
->getSession()
->getPage();
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field/display';
// Enable Layout Builder for the default view modes, and overrides.
$this
->drupalGet("{$field_ui_prefix}/default");
$page
->checkField('layout[enabled]');
$page
->pressButton('Save');
$page
->checkField('layout[allow_custom]');
$page
->pressButton('Save');
// Create a node.
$this->node = $this
->createNode([
'type' => 'bundle_with_section_field',
'title' => 'A node at rest will stay at rest.',
]);
$add_block_text = 'Add block';
if (version_compare(\Drupal::VERSION, '8.8.0', '<')) {
$add_block_text = ucwords($add_block_text);
}
$this
->drupalGet('node/' . $this->node
->id() . '/layout');
$page
->clickLink($add_block_text);
$page
->clickLink('Powered by Drupal');
$page
->fillField('settings[label]', 'This is an override');
$page
->checkField('settings[label_display]');
$page
->pressButton($add_block_text);
$page
->pressButton('Save layout');
$assert_session
->pageTextContains('This is an override');
$this->nodeStorage = $this->container
->get('entity_type.manager')
->getStorage('node');
$this->node = $this->nodeStorage
->load($this->node
->id());
$this
->drupalLogout();
$this
->setUpAuthorization('ALL');
$this
->provisionResource([
static::$format,
], [
'basic_auth',
]);
}