Mercurial > hg > isophonics-drupal-site
diff core/modules/contact/tests/src/Functional/ContactLanguageTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/contact/tests/src/Functional/ContactLanguageTest.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,64 @@ +<?php + +namespace Drupal\Tests\contact\Functional; + +use Drupal\Tests\BrowserTestBase; + +/** + * Tests contact messages with language module. + * + * This is to ensure that a contact form by default does not show the language + * select, but it does so when it's enabled from the content language settings + * page. + * + * @group contact + */ +class ContactLanguageTest extends BrowserTestBase { + + /** + * Modules to enable. + * + * @var array + */ + public static $modules = [ + 'contact', + 'language', + 'contact_test', + ]; + + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + + // Create and log in administrative user. + $admin_user = $this->drupalCreateUser([ + 'access site-wide contact form', + 'administer languages', + ]); + $this->drupalLogin($admin_user); + } + + /** + * Tests configuration options with language enabled. + */ + public function testContactLanguage() { + // Ensure that contact form by default does not show the language select. + $this->drupalGet('contact'); + $this->assertResponse(200, 'The page exists'); + $this->assertNoField('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->drupalPostForm($settings_path, $edit, t('Save configuration')); + + // Ensure that contact form now shows the language select. + $this->drupalGet('contact'); + $this->assertResponse(200, 'The page exists'); + $this->assertField('edit-langcode-0-value'); + } + +}