You are here

protected function LayoutBuilderAtBase::addLayoutOverride in Layout Builder Asymmetric Translation 8.2

Adds a layout override.

Parameters

bool $add_text_block:

string $custom_block_content_body:

Throws

\Behat\Mink\Exception\ElementNotFoundException

\Behat\Mink\Exception\ExpectationException

\Behat\Mink\Exception\ResponseTextException

\Drupal\Core\Entity\EntityMalformedException

2 calls to LayoutBuilderAtBase::addLayoutOverride()
LayoutBuilderAtReplicateTest::testAsymmetricTranslationWithReplicate in tests/src/Functional/LayoutBuilderAtReplicateTest.php
Tests that layout overrides have copied blocks.
LayoutBuilderAtTranslationTest::testAsymmetricTranslation in tests/src/Functional/LayoutBuilderAtTranslationTest.php
Tests that layout overrides have different blocks.

File

tests/src/Functional/LayoutBuilderAtBase.php, line 164

Class

LayoutBuilderAtBase
Base class for Layout Builder Asymmetric Translations.

Namespace

Drupal\Tests\layout_builder_at\Functional

Code

protected function addLayoutOverride($add_text_block = FALSE, $custom_block_content_body = self::defaultContentBlockBody) {
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $entity_url = $this->entity
    ->toUrl()
    ->toString();
  $layout_url = $entity_url . '/layout';
  $this
    ->drupalGet($layout_url);
  $assert_session
    ->pageTextNotContains(self::translatedTextFieldText);
  $assert_session
    ->pageTextContains(self::defaultTextFieldText);

  // Adjust the layout.
  $this
    ->click('.layout-builder__add-block .layout-builder__link');
  $assert_session
    ->linkExists('Powered by Drupal');
  $this
    ->clickLink('Powered by Drupal');
  $button = $assert_session
    ->elementExists('css', '#layout-builder-add-block .button--primary');
  $button
    ->press();
  $assert_session
    ->pageTextContains('Powered by Drupal');
  if ($add_text_block) {
    $this
      ->click('.layout-builder__add-block .layout-builder__link');
    $this
      ->clickLink('Create custom block');
    $edit = [
      'settings[label]' => 'Label',
      'settings[label_display]' => FALSE,
      'settings[block_form][body][0][value]' => $custom_block_content_body,
    ];
    $this
      ->drupalPostForm(NULL, $edit, $button
      ->getValue());
  }
  $assert_session
    ->buttonExists('Save layout');
  $page
    ->pressButton('Save layout');
}