BlockLanguageCacheTest.php in Zircon Profile 8
File
core/modules/block/src/Tests/BlockLanguageCacheTest.php
View source
<?php
namespace Drupal\block\Tests;
use Drupal\Component\Utility\Unicode;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
class BlockLanguageCacheTest extends WebTestBase {
public static $modules = array(
'block',
'language',
'menu_ui',
);
protected $langcodes = array();
protected function setUp() {
parent::setUp();
$this->langcodes = array(
ConfigurableLanguage::load('en'),
);
for ($i = 1; $i < 3; ++$i) {
$language = ConfigurableLanguage::create(array(
'id' => 'l' . $i,
'label' => $this
->randomString(),
));
$language
->save();
$this->langcodes[$i] = $language;
}
}
public function testBlockLinks() {
$admin_user = $this
->drupalCreateUser(array(
'administer blocks',
'access administration pages',
'administer menu',
));
$this
->drupalLogin($admin_user);
foreach ($this->langcodes as $langcode) {
$this
->drupalGet('admin/structure/block', array(
'language' => $langcode,
));
$this
->clickLinkPartialName('Place block');
}
$edit['label'] = $this
->randomMachineName();
$edit['id'] = Unicode::strtolower($edit['label']);
$this
->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
$this
->assertText(t('Menu @label has been added.', array(
'@label' => $edit['label'],
)));
foreach ($this->langcodes as $langcode) {
$this
->drupalGet('admin/structure/block', array(
'language' => $langcode,
));
$this
->clickLinkPartialName('Place block');
$this
->assertText($edit['label']);
}
}
}