BlockLanguageCacheTest.php in Drupal 8
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 {
public static $modules = [
'block',
'language',
'menu_ui',
];
protected $defaultTheme = 'stark';
protected $langcodes = [];
protected function setUp() {
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
->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
$this
->assertText(t('Menu @label has been added.', [
'@label' => $edit['label'],
]));
foreach ($this->langcodes as $langcode) {
$this
->drupalGet('admin/structure/block', [
'language' => $langcode,
]);
$this
->clickLink('Place block');
$this
->assertText($edit['label']);
}
}
}