function BlockLanguageTest::setUp

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

Overrides BrowserTestBase::setUp

File

core/modules/block/tests/src/Functional/BlockLanguageTest.php, line 35

Class

BlockLanguageTest
Tests per-language block configuration.

Namespace

Drupal\Tests\block\Functional

Code

protected function setUp() : void {
    parent::setUp();
    $this->adminUser = $this->drupalCreateUser([
        'administer blocks',
        'administer languages',
    ]);
    $this->drupalLogin($this->adminUser);
    // Add predefined language.
    $edit = [
        'predefined_langcode' => 'fr',
    ];
    $this->drupalGet('admin/config/regional/language/add');
    $this->submitForm($edit, 'Add language');
    // Verify that language was added successfully.
    $this->assertSession()
        ->pageTextContains('French');
    // Set path prefixes for both languages.
    $this->config('language.negotiation')
        ->set('url', [
        'source' => 'path_prefix',
        'prefixes' => [
            'en' => 'en',
            'fr' => 'fr',
        ],
    ])
        ->save();
    $this->drupalCreateContentType([
        'type' => 'page',
    ]);
    $this->drupalCreateNode();
}

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