TranslatedViewTest.php in Drupal 10
File
core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php
View source
<?php
namespace Drupal\Tests\views_ui\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
class TranslatedViewTest extends UITestBase {
protected static $modules = [
'config_translation',
'views_ui',
];
protected $defaultTheme = 'stark';
protected $langcodes = [
'fr',
];
protected $adminUser;
protected function setUp($import_test_views = TRUE, $modules = []) : void {
parent::setUp($import_test_views, $modules);
$permissions = [
'administer site configuration',
'administer views',
'translate configuration',
'translate interface',
];
$this->adminUser = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($this->adminUser);
foreach ($this->langcodes as $langcode) {
ConfigurableLanguage::createFromLangcode($langcode)
->save();
}
$this
->resetAll();
$this
->rebuildContainer();
}
public function testTranslatedStrings() {
$translation_url = 'admin/structure/views/view/files/translate/fr/add';
$edit_url = 'admin/structure/views/view/files';
$this
->drupalGet($edit_url);
$this
->assertSession()
->titleEquals('Files (File) | Drupal');
$this
->drupalGet($translation_url);
$edit = [
'translation[config_names][views.view.files][label]' => 'Fichiers',
];
$this
->submitForm($edit, 'Save translation');
$this
->drupalGet($edit_url, [
'language' => \Drupal::languageManager()
->getLanguage('fr'),
]);
$this
->assertSession()
->titleEquals('Files (File) | Drupal');
$this
->assertSession()
->pageTextNotContains('Fichiers');
$this
->drupalGet($edit_url);
$this
->submitForm([], 'Add Block');
$this
->drupalGet('admin/structure/views/nojs/display/files/block_1/link_display');
$edit = [
'link_display' => 'custom_url',
'link_url' => '/node',
];
$this
->submitForm($edit, 'Apply');
$this
->submitForm([], 'Save');
$this
->drupalGet('admin/structure/views/nojs/handler/files/block_1/field/filename');
$edit = [
'override[dropdown]' => 'block_1',
'options[type]' => 'string',
'options[alter][path]' => '/node',
'options[alter][make_link]' => 1,
];
$this
->submitForm($edit, 'Apply');
$this
->submitForm([], 'Save');
$this
->drupalGet($translation_url);
$this
->assertSession()
->fieldExists('translation[config_names][views.view.files][display][block_1][display_options][fields][filename][alter][path]');
$this
->assertSession()
->fieldExists('translation[config_names][views.view.files][display][default][display_options][link_url]');
}
}
Classes
Name |
Description |
TranslatedViewTest |
Tests that translated strings in views UI don't override original strings. |