function ContactLanguageTest::testContactLanguage

Same name in other branches
  1. 8.9.x core/modules/contact/tests/src/Functional/ContactLanguageTest.php \Drupal\Tests\contact\Functional\ContactLanguageTest::testContactLanguage()
  2. 10 core/modules/contact/tests/src/Functional/ContactLanguageTest.php \Drupal\Tests\contact\Functional\ContactLanguageTest::testContactLanguage()
  3. 11.x core/modules/contact/tests/src/Functional/ContactLanguageTest.php \Drupal\Tests\contact\Functional\ContactLanguageTest::testContactLanguage()

Tests configuration options with language enabled.

File

core/modules/contact/tests/src/Functional/ContactLanguageTest.php, line 51

Class

ContactLanguageTest
Tests contact messages with language module.

Namespace

Drupal\Tests\contact\Functional

Code

public function testContactLanguage() {
    // Ensure that contact form by default does not show the language select.
    $this->drupalGet('contact');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->fieldNotExists('edit-langcode-0-value');
    // Enable language select from content language settings page.
    $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');
    // Ensure that contact form now shows the language select.
    $this->drupalGet('contact');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->fieldExists('edit-langcode-0-value');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.