You are here

public function FixedBlockAdminTest::doTestExportConfirmFormWithDefaultContentOverExisting in Fixed Block Content 8

Tests the default content export confirm form over existing block.

See also

\Drupal\fixed_block_content\Form\ExportConfirmForm

1 call to FixedBlockAdminTest::doTestExportConfirmFormWithDefaultContentOverExisting()
FixedBlockAdminTest::testAdmin in tests/src/Functional/FixedBlockAdminTest.php
Full admin test sequence.

File

tests/src/Functional/FixedBlockAdminTest.php, line 141

Class

FixedBlockAdminTest
Tests the fixed block content admin.

Namespace

Drupal\Tests\fixed_block_content\Functional

Code

public function doTestExportConfirmFormWithDefaultContentOverExisting() {

  // Set arbitrary body content in the existing block content.
  $block_content = $this->fixedBlock
    ->getBlockContent(FALSE);
  $block_content
    ->get('body')
    ->setValue($this
    ->randomString(128));
  $block_content
    ->save();

  // Go to export (restore) block with the default content page.
  $this
    ->drupalGet('admin/structure/block/block-content/fixed-block-content/manage/basic_fixed/export');

  // The update existing option must be present.
  $this
    ->assertText('Update the existing block content');

  // Proceed enabling the update existing option.
  $this
    ->drupalPostForm(NULL, [
    'update_existing' => TRUE,
  ], 'Confirm');

  // The block content must be the same as the previously existing.
  $new_block_content = $this->fixedBlock
    ->getBlockContent(FALSE);
  $this
    ->assertEquals($block_content
    ->id(), $new_block_content
    ->id());
  $this
    ->assertEquals($block_content
    ->uuid(), $new_block_content
    ->uuid());

  // The body content must be updated to the defaults.
  $this
    ->assertEquals($new_block_content
    ->get('body')
    ->getString(), $this->randomContent);
}