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