Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Tests\contact\Functional;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Tests\BrowserTestBase;
|
Chris@0
|
6
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Tests contact messages with language module.
|
Chris@0
|
9 *
|
Chris@0
|
10 * This is to ensure that a contact form by default does not show the language
|
Chris@0
|
11 * select, but it does so when it's enabled from the content language settings
|
Chris@0
|
12 * page.
|
Chris@0
|
13 *
|
Chris@0
|
14 * @group contact
|
Chris@0
|
15 */
|
Chris@0
|
16 class ContactLanguageTest extends BrowserTestBase {
|
Chris@0
|
17
|
Chris@0
|
18 /**
|
Chris@0
|
19 * Modules to enable.
|
Chris@0
|
20 *
|
Chris@0
|
21 * @var array
|
Chris@0
|
22 */
|
Chris@0
|
23 public static $modules = [
|
Chris@0
|
24 'contact',
|
Chris@0
|
25 'language',
|
Chris@0
|
26 'contact_test',
|
Chris@0
|
27 ];
|
Chris@0
|
28
|
Chris@0
|
29 /**
|
Chris@0
|
30 * {@inheritdoc}
|
Chris@0
|
31 */
|
Chris@0
|
32 protected function setUp() {
|
Chris@0
|
33 parent::setUp();
|
Chris@0
|
34
|
Chris@0
|
35 // Create and log in administrative user.
|
Chris@0
|
36 $admin_user = $this->drupalCreateUser([
|
Chris@0
|
37 'access site-wide contact form',
|
Chris@0
|
38 'administer languages',
|
Chris@0
|
39 ]);
|
Chris@0
|
40 $this->drupalLogin($admin_user);
|
Chris@0
|
41 }
|
Chris@0
|
42
|
Chris@0
|
43 /**
|
Chris@0
|
44 * Tests configuration options with language enabled.
|
Chris@0
|
45 */
|
Chris@0
|
46 public function testContactLanguage() {
|
Chris@0
|
47 // Ensure that contact form by default does not show the language select.
|
Chris@0
|
48 $this->drupalGet('contact');
|
Chris@0
|
49 $this->assertResponse(200, 'The page exists');
|
Chris@0
|
50 $this->assertNoField('edit-langcode-0-value');
|
Chris@0
|
51
|
Chris@0
|
52 // Enable language select from content language settings page.
|
Chris@0
|
53 $settings_path = 'admin/config/regional/content-language';
|
Chris@0
|
54 $edit['entity_types[contact_message]'] = TRUE;
|
Chris@0
|
55 $edit['settings[contact_message][feedback][settings][language][language_alterable]'] = TRUE;
|
Chris@0
|
56 $this->drupalPostForm($settings_path, $edit, t('Save configuration'));
|
Chris@0
|
57
|
Chris@0
|
58 // Ensure that contact form now shows the language select.
|
Chris@0
|
59 $this->drupalGet('contact');
|
Chris@0
|
60 $this->assertResponse(200, 'The page exists');
|
Chris@0
|
61 $this->assertField('edit-langcode-0-value');
|
Chris@0
|
62 }
|
Chris@0
|
63
|
Chris@0
|
64 }
|