You are here

public function ViewsUITourTest::testViewsUiTourTipsTranslated in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views_ui/src/Tests/ViewsUITourTest.php \Drupal\views_ui\Tests\ViewsUITourTest::testViewsUiTourTipsTranslated()

Tests views_ui tour tip availability in a different language.

File

core/modules/views_ui/src/Tests/ViewsUITourTest.php, line 64
Contains \Drupal\views_ui\Tests\ViewsUITourTest.

Class

ViewsUITourTest
Tests the Views UI tour.

Namespace

Drupal\views_ui\Tests

Code

public function testViewsUiTourTipsTranslated() {
  $langcode = 'nl';

  // Add a default locale storage for this test.
  $this->localeStorage = $this->container
    ->get('locale.storage');

  // Add Dutch language programmatically.
  ConfigurableLanguage::createFromLangcode($langcode)
    ->save();

  // Handler titles that need translations.
  $handler_titles = array(
    'Format',
    'Fields',
    'Sort criteria',
    'Filter criteria',
  );
  foreach ($handler_titles as $handler_title) {

    // Create source string.
    $source = $this->localeStorage
      ->createString(array(
      'source' => $handler_title,
    ));
    $source
      ->save();
    $this
      ->createTranslation($source, $langcode);
  }

  // Create a basic view that shows all content, with a page and a block
  // display.
  $view['label'] = $this
    ->randomMachineName(16);
  $view['id'] = strtolower($this
    ->randomMachineName(16));
  $view['page[create]'] = 1;
  $view['page[path]'] = $this
    ->randomMachineName(16);

  // Load the page in dutch.
  $this
    ->drupalPostForm($langcode . '/admin/structure/views/add', $view, t('Save and edit'));
  $this
    ->assertTourTips();
}