ContactLanguageTest.php in Drupal 9
File
core/modules/contact/tests/src/Functional/ContactLanguageTest.php
View source
<?php
namespace Drupal\Tests\contact\Functional;
use Drupal\Tests\BrowserTestBase;
class ContactLanguageTest extends BrowserTestBase {
protected static $modules = [
'contact',
'language',
'contact_test',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$admin_user = $this
->drupalCreateUser([
'access site-wide contact form',
'administer languages',
]);
$this
->drupalLogin($admin_user);
}
public function testContactLanguage() {
$this
->drupalGet('contact');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->fieldNotExists('edit-langcode-0-value');
$settings_path = 'admin/config/regional/content-language';
$edit['entity_types[contact_message]'] = TRUE;
$edit['settings[contact_message][feedback][settings][language][language_alterable]'] = TRUE;
$this
->drupalGet($settings_path);
$this
->submitForm($edit, 'Save configuration');
$this
->drupalGet('contact');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->fieldExists('edit-langcode-0-value');
}
}