You are here

public function DefaultContentTest::testDefaultContentImport in Fixed Block Content 8

Tests the default content import.

That is, copy the current block contents to the fixed block content configuration.

@covers ::importDefaultContent

File

tests/src/Kernel/DefaultContentTest.php, line 61

Class

DefaultContentTest
Tests the fixed block default content management.

Namespace

Drupal\Tests\fixed_block_content\Kernel

Code

public function testDefaultContentImport() {

  // Basic import default content test.
  $this->fixedBlock
    ->importDefaultContent();
  $block_content = $this->fixedBlock
    ->getBlockContent(FALSE);

  // Import in an empty fixed block will create a new block content.
  $this
    ->assertNotNull($block_content);

  // The default_content property must has some value.
  $this
    ->assertNotEmpty($this->fixedBlock
    ->get('default_content'));

  // Tests default content update.
  $test_content = 'To be imported.';
  $block_content
    ->get('body')
    ->setValue($test_content);
  $block_content
    ->save();
  $this->fixedBlock
    ->importDefaultContent();
  $this
    ->assertContains($test_content, $this->fixedBlock
    ->get('default_content'));
}