3 namespace Drupal\Tests\views_ui\Functional;
5 use Drupal\Tests\tour\Functional\TourTestBase;
6 use Drupal\language\Entity\ConfigurableLanguage;
9 * Tests the Views UI tour.
13 class ViewsUITourTest extends TourTestBase {
16 * An admin user with administrative permissions for views.
18 * @var \Drupal\user\UserInterface
23 * String translation storage object.
25 * @var \Drupal\locale\StringStorageInterface
27 protected $localeStorage;
34 public static $modules = ['views_ui', 'tour', 'language', 'locale'];
36 protected function setUp() {
38 $this->adminUser = $this->drupalCreateUser(['administer views', 'access tour']);
39 $this->drupalLogin($this->adminUser);
43 * Tests views_ui tour tip availability.
45 public function testViewsUiTourTips() {
46 // Create a basic view that shows all content, with a page and a block
48 $view['label'] = $this->randomMachineName(16);
49 $view['id'] = strtolower($this->randomMachineName(16));
50 $view['page[create]'] = 1;
51 $view['page[path]'] = $this->randomMachineName(16);
52 $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
53 $this->assertTourTips();
57 * Tests views_ui tour tip availability in a different language.
59 public function testViewsUiTourTipsTranslated() {
62 // Add a default locale storage for this test.
63 $this->localeStorage = $this->container->get('locale.storage');
65 // Add Dutch language programmatically.
66 ConfigurableLanguage::createFromLangcode($langcode)->save();
68 // Handler titles that need translations.
76 foreach ($handler_titles as $handler_title) {
77 // Create source string.
78 $source = $this->localeStorage->createString([
79 'source' => $handler_title,
82 $this->createTranslation($source, $langcode);
85 // Create a basic view that shows all content, with a page and a block
87 $view['label'] = $this->randomMachineName(16);
88 $view['id'] = strtolower($this->randomMachineName(16));
89 $view['page[create]'] = 1;
90 $view['page[path]'] = $this->randomMachineName(16);
91 // Load the page in dutch.
92 $this->drupalPostForm(
93 $langcode . '/admin/structure/views/add',
97 $this->assertTourTips();
101 * Creates single translation for source string.
103 public function createTranslation($source, $langcode) {
104 return $this->localeStorage->createTranslation([
105 'lid' => $source->lid,
106 'language' => $langcode,
107 'translation' => $this->randomMachineName(100),