BlockLanguageCacheTest.php in Drupal 10
File
core/modules/block/tests/src/Functional/BlockLanguageCacheTest.php
View source
<?php
namespace Drupal\Tests\block\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
class BlockLanguageCacheTest extends BrowserTestBase {
protected static $modules = [
'block',
'language',
'menu_ui',
];
protected $defaultTheme = 'stark';
protected $langcodes = [];
protected function setUp() : void {
parent::setUp();
$this->langcodes = [
ConfigurableLanguage::load('en'),
];
for ($i = 1; $i < 3; ++$i) {
$language = ConfigurableLanguage::create([
'id' => 'l' . $i,
'label' => $this
->randomString(),
]);
$language
->save();
$this->langcodes[$i] = $language;
}
}
public function testBlockLinks() {
$admin_user = $this
->drupalCreateUser([
'administer blocks',
'access administration pages',
'administer menu',
]);
$this
->drupalLogin($admin_user);
foreach ($this->langcodes as $langcode) {
$this
->drupalGet('admin/structure/block', [
'language' => $langcode,
]);
$this
->clickLink('Place block');
}
$edit['label'] = $this
->randomMachineName();
$edit['id'] = mb_strtolower($edit['label']);
$this
->drupalGet('admin/structure/menu/add');
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('Menu ' . $edit['label'] . ' has been added.');
foreach ($this->langcodes as $langcode) {
$this
->drupalGet('admin/structure/block', [
'language' => $langcode,
]);
$this
->clickLink('Place block');
$this
->assertSession()
->pageTextContains($edit['label']);
}
}
}