3 namespace Drupal\contact\Tests\Update;
5 use Drupal\system\Tests\Update\UpdatePathTestBase;
8 * Tests contact update path.
12 class ContactUpdateTest extends UpdatePathTestBase {
17 protected function setDatabaseDumpFiles() {
18 $this->databaseDumpFiles = [
19 __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
24 * Tests contact_form updates.
26 * @see contact_post_update_add_message_redirect_field_to_contact_form()
28 public function testPostUpdateContactFormFields() {
29 // Check that contact_form does not have fields redirect and message.
30 $config_factory = \Drupal::configFactory();
31 // Check that contact_form entities are more than zero.
32 $contact_forms = $config_factory->listAll('contact.form.');
33 $this->assertTrue(count($contact_forms), 'There are contact forms to update.');
34 foreach ($contact_forms as $contact_config_name) {
35 $contact_form_data = $config_factory->get($contact_config_name)->get();
36 $this->assertFalse(isset($contact_form_data['message']), 'Prior to running the update the "message" key does not exist.');
37 $this->assertFalse(isset($contact_form_data['redirect']), 'Prior to running the update the "redirect" key does not exist.');
43 // Check that the contact_form entities have been updated.
44 foreach ($contact_forms as $contact_config_name) {
45 $contact_form_data = $config_factory->get($contact_config_name)->get();
46 $this->assertTrue(isset($contact_form_data['message']), 'After running the update the "message" key exists.');
47 $this->assertEqual('Your message has been sent.', $contact_form_data['message']);
48 $this->assertTrue(isset($contact_form_data['redirect']), 'After running the update the "redirect" key exists.');
49 $this->assertEqual('', $contact_form_data['redirect']);