class ConfigTranslationListUiTest
Ensure the "translate" link is added to contact forms.
Attributes
#[Group('contact')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\contact\Functional\ConfigTranslationListUiTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ConfigTranslationListUiTest
See also
\Drupal\Tests\config_translation\Functional\ConfigTranslationListUiTest
File
-
core/
modules/ contact/ tests/ src/ Functional/ ConfigTranslationListUiTest.php, line 17
Namespace
Drupal\Tests\contact\FunctionalView source
class ConfigTranslationListUiTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'block',
'config_translation',
'contact',
'toolbar',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Admin user with all needed permissions.
*
* @var \Drupal\user\Entity\User
*/
protected $adminUser;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$permissions = [
'access site-wide contact form',
'administer contact forms',
'translate configuration',
];
// Create and log in user.
$this->adminUser = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->adminUser);
// Enable import of translations. By default this is disabled for automated
// tests.
$this->config('locale.settings')
->set('translation.import_enabled', TRUE)
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
->save();
$this->drupalPlaceBlock('local_tasks_block');
}
/**
* Tests the contact forms listing for the translate operation.
*/
public function testContactFormsList() : void {
// Create a test contact form to decouple looking for translate operations
// link so this does not test more than necessary.
$contact_form = ContactForm::create([
'id' => $this->randomMachineName(16),
'label' => $this->randomMachineName(),
]);
$contact_form->save();
// Get the contact form listing.
$this->drupalGet('admin/structure/contact');
$translate_link = 'admin/structure/contact/manage/' . $contact_form->id() . '/translate';
// Test if the link to translate the contact form is on the page.
$this->assertSession()
->linkByHrefExists($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertSession()
->responseContains('<th>Language</th>');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.