function ViewsUITourTest::testViewsUiTourTipsTranslated

Same name and namespace in other branches
  1. 9 core/modules/views_ui/tests/src/Functional/ViewsUITourTest.php \Drupal\Tests\views_ui\Functional\ViewsUITourTest::testViewsUiTourTipsTranslated()
  2. 8.9.x core/modules/views_ui/tests/src/Functional/ViewsUITourTest.php \Drupal\Tests\views_ui\Functional\ViewsUITourTest::testViewsUiTourTipsTranslated()
  3. 10 core/modules/tour/tests/src/Functional/ViewsUi/ViewsUITourTest.php \Drupal\Tests\tour\Functional\ViewsUi\ViewsUITourTest::testViewsUiTourTipsTranslated()

Tests views_ui tour tip availability in a different language.

File

core/modules/tour/tests/src/Functional/ViewsUi/ViewsUITourTest.php, line 74

Class

ViewsUITourTest
Tests the Views UI tour.

Namespace

Drupal\Tests\tour\Functional\ViewsUi

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 = [
        'Format',
        'Fields',
        'Sort criteria',
        'Filter criteria',
    ];
    foreach ($handler_titles as $handler_title) {
        // Create source string.
        $source = $this->localeStorage
            ->createString([
            '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'] = $this->randomMachineName(16);
    $view['page[create]'] = 1;
    $view['page[path]'] = $this->randomMachineName(16);
    // Load the page in dutch.
    $this->drupalGet($langcode . '/admin/structure/views/add');
    $this->submitForm($view, 'Save and edit');
    $this->assertTourTips();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.