ViewsUITourTest.php in Drupal 10
File
core/modules/views_ui/tests/src/Functional/ViewsUITourTest.php
View source
<?php
namespace Drupal\Tests\views_ui\Functional;
use Drupal\Tests\tour\Functional\TourTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
class ViewsUITourTest extends TourTestBase {
protected $adminUser;
protected $defaultTheme = 'stark';
protected $localeStorage;
protected static $modules = [
'views_ui',
'tour',
'language',
'locale',
];
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'administer views',
'access tour',
]);
$this
->drupalLogin($this->adminUser);
}
public function testViewsUiTourTips() {
$view['label'] = $this
->randomMachineName(16);
$view['id'] = strtolower($this
->randomMachineName(16));
$view['page[create]'] = 1;
$view['page[path]'] = $this
->randomMachineName(16);
$this
->drupalGet('admin/structure/views/add');
$this
->submitForm($view, 'Save and edit');
$this
->assertTourTips();
}
public function testViewsUiTourTipsTranslated() {
$langcode = 'nl';
$this->localeStorage = $this->container
->get('locale.storage');
ConfigurableLanguage::createFromLangcode($langcode)
->save();
$handler_titles = [
'Format',
'Fields',
'Sort criteria',
'Filter criteria',
];
foreach ($handler_titles as $handler_title) {
$source = $this->localeStorage
->createString([
'source' => $handler_title,
]);
$source
->save();
$this
->createTranslation($source, $langcode);
}
$view['label'] = $this
->randomMachineName(16);
$view['id'] = strtolower($this
->randomMachineName(16));
$view['page[create]'] = 1;
$view['page[path]'] = $this
->randomMachineName(16);
$this
->drupalGet($langcode . '/admin/structure/views/add');
$this
->submitForm($view, 'Save and edit');
$this
->assertTourTips();
}
public function createTranslation($source, $langcode) {
return $this->localeStorage
->createTranslation([
'lid' => $source->lid,
'language' => $langcode,
'translation' => $this
->randomMachineName(100),
])
->save();
}
}