function BlockUiTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::setUp()
  2. 8.9.x core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::setUp()
  3. 10 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/block/tests/src/Functional/BlockUiTest.php, line 63

Class

BlockUiTest
Tests that the block configuration UI exists and stores data correctly.

Namespace

Drupal\Tests\block\Functional

Code

protected function setUp() : void {
    parent::setUp();
    // Create and log in an administrative user.
    $this->adminUser = $this->drupalCreateUser([
        'administer blocks',
        'access administration pages',
    ]);
    $this->drupalLogin($this->adminUser);
    // Enable some test blocks.
    $this->blockValues = [
        [
            'label' => 'Tools',
            'tr' => '6',
            'plugin_id' => 'system_menu_block:tools',
            'settings' => [
                'region' => 'sidebar_second',
                'id' => 'tools',
            ],
            'test_weight' => '-1',
        ],
        [
            'label' => 'Powered by Drupal',
            'tr' => '17',
            'plugin_id' => 'system_powered_by_block',
            'settings' => [
                'region' => 'footer',
                'id' => 'powered',
            ],
            'test_weight' => '0',
        ],
    ];
    $this->blocks = [];
    foreach ($this->blockValues as $values) {
        $this->blocks[] = $this->drupalPlaceBlock($values['plugin_id'], $values['settings']);
    }
}

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