You are here

public function EntityTypeAlterTest::testBlockTree in Workspace 8

Tests revision tree of block content.

File

tests/src/Functional/EntityTypeAlterTest.php, line 88

Class

EntityTypeAlterTest
Test the workspace entity.

Namespace

Drupal\Tests\workspace\Functional

Code

public function testBlockTree() {
  $permissions = [
    'administer blocks',
    'view_revision_trees',
  ];
  $user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($user);

  // Create new block type.
  $block_type = BlockContentType::create([
    'id' => 'basic',
    'label' => 'basic',
  ]);
  $block_type
    ->save();

  // Create new block.
  $block_content = BlockContent::create([
    'info' => $this
      ->randomString(),
    'type' => 'basic',
    'langcode' => 'en',
  ]);
  $block_content
    ->save();

  // Check for tree elements.
  $this
    ->drupalGet('/block/' . $block_content
    ->id() . '/tree');
  $this
    ->assertSession()
    ->pageTextContains('Status: available');

  // Update block.
  $edit['info[0][value]'] = $this
    ->randomMachineName(16);
  $this
    ->drupalPostForm('block/' . $block_content
    ->id(), $edit, t('Save'));
  $this
    ->drupalGet('/block/' . $block_content
    ->id() . '/tree');
  $this
    ->assertSession()
    ->pageTextContains('Status: available');
}