You are here

public function BlockLanguageCacheTest::testBlockLinks in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/block/src/Tests/BlockLanguageCacheTest.php \Drupal\block\Tests\BlockLanguageCacheTest::testBlockLinks()

Creates a block in a language, check blocks page in all languages.

File

core/modules/block/src/Tests/BlockLanguageCacheTest.php, line 53
Contains \Drupal\block\Tests\BlockLanguageCacheTest.

Class

BlockLanguageCacheTest
Tests display of menu blocks with multiple languages.

Namespace

Drupal\block\Tests

Code

public function testBlockLinks() {

  // Create admin user to be able to access block admin.
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer blocks',
    'access administration pages',
    'administer menu',
  ));
  $this
    ->drupalLogin($admin_user);

  // Create the block cache for all languages.
  foreach ($this->langcodes as $langcode) {
    $this
      ->drupalGet('admin/structure/block', array(
      'language' => $langcode,
    ));
    $this
      ->clickLinkPartialName('Place block');
  }

  // Create a menu in the default language.
  $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'],
  )));

  // Check that the block is listed for all languages.
  foreach ($this->langcodes as $langcode) {
    $this
      ->drupalGet('admin/structure/block', array(
      'language' => $langcode,
    ));
    $this
      ->clickLinkPartialName('Place block');
    $this
      ->assertText($edit['label']);
  }
}