You are here

protected function BlockLanguageTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block/tests/src/Functional/BlockLanguageTest.php \Drupal\Tests\block\Functional\BlockLanguageTest::setUp()
  2. 9 core/modules/block/tests/src/Functional/BlockLanguageTest.php \Drupal\Tests\block\Functional\BlockLanguageTest::setUp()

File

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

Class

BlockLanguageTest
Tests if a block can be configured to be only visible on a particular language.

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();
}