public function BlockLanguageCacheTest::testBlockLinks

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

File

drupal/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php, line 58
Contains \Drupal\block\Tests\BlockLanguageCacheTest.

Class

BlockLanguageCacheTest
Tests multilingual block definition caching.

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 news feeds',
    'access news feeds',
    'create article content',
    'administer languages',
  ));
  $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
      ->clickLink(t('Place blocks'));
  }

  // Create a feed in the default language.
  $this
    ->createSampleNodes();
  $feed = $this
    ->createFeed();

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