function BlockContentUpdateTest::testMoveCustomBlockLibraryToContent

Same name in other branches
  1. 11.x core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php \Drupal\Tests\block_content\Functional\Update\BlockContentUpdateTest::testMoveCustomBlockLibraryToContent()

Tests moving the content block library to Content.

See also

block_content_post_update_move_custom_block_library()

File

core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php, line 59

Class

BlockContentUpdateTest
Tests update functions for the Block Content module.

Namespace

Drupal\Tests\block_content\Functional\Update

Code

public function testMoveCustomBlockLibraryToContent() : void {
    $user = $this->drupalCreateUser([
        'administer blocks',
    ]);
    $this->drupalLogin($user);
    $this->drupalGet('admin/structure/block/block-content');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->pageTextContains('Custom blocks');
    $this->assertSession()
        ->pageTextContains('Custom block library');
    $this->drupalGet('admin/content/block');
    $this->assertSession()
        ->statusCodeEquals(404);
    $this->runUpdates();
    // Load and initialize the block_content view.
    $view = View::load('block_content');
    $data = $view->toArray();
    // Check that the path, description, and menu options have been updated.
    $this->assertEquals('admin/content/block', $data['display']['page_1']['display_options']['path']);
    $this->assertEquals('Create and edit block content.', $data['display']['page_1']['display_options']['menu']['description']);
    $this->assertFalse($data['display']['page_1']['display_options']['menu']['expanded']);
    $this->assertEquals('system.admin_content', $data['display']['page_1']['display_options']['menu']['parent']);
    $this->assertEquals('Content blocks', $view->label());
    $this->assertEquals('Blocks', $data['display']['page_1']['display_options']['menu']['title']);
    // Check the new path is accessible.
    $user = $this->drupalCreateUser([
        'access block library',
    ]);
    $this->drupalLogin($user);
    $this->drupalGet('admin/content/block');
    $this->assertSession()
        ->statusCodeEquals(200);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.