X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontact%2Fsrc%2FTests%2FUpdate%2FContactUpdateTest.php;fp=web%2Fcore%2Fmodules%2Fcontact%2Fsrc%2FTests%2FUpdate%2FContactUpdateTest.php;h=4cbfd64aaa64e2ce5715ea5c14957e749dcf4d39;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/contact/src/Tests/Update/ContactUpdateTest.php b/web/core/modules/contact/src/Tests/Update/ContactUpdateTest.php new file mode 100644 index 000000000..4cbfd64aa --- /dev/null +++ b/web/core/modules/contact/src/Tests/Update/ContactUpdateTest.php @@ -0,0 +1,53 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz', + ]; + } + + /** + * Tests contact_form updates. + * + * @see contact_post_update_add_message_redirect_field_to_contact_form() + */ + public function testPostUpdateContactFormFields() { + // Check that contact_form does not have fields redirect and message. + $config_factory = \Drupal::configFactory(); + // Check that contact_form entities are more than zero. + $contact_forms = $config_factory->listAll('contact.form.'); + $this->assertTrue(count($contact_forms), 'There are contact forms to update.'); + foreach ($contact_forms as $contact_config_name) { + $contact_form_data = $config_factory->get($contact_config_name)->get(); + $this->assertFalse(isset($contact_form_data['message']), 'Prior to running the update the "message" key does not exist.'); + $this->assertFalse(isset($contact_form_data['redirect']), 'Prior to running the update the "redirect" key does not exist.'); + } + + // Run updates. + $this->runUpdates(); + + // Check that the contact_form entities have been updated. + foreach ($contact_forms as $contact_config_name) { + $contact_form_data = $config_factory->get($contact_config_name)->get(); + $this->assertTrue(isset($contact_form_data['message']), 'After running the update the "message" key exists.'); + $this->assertEqual('Your message has been sent.', $contact_form_data['message']); + $this->assertTrue(isset($contact_form_data['redirect']), 'After running the update the "redirect" key exists.'); + $this->assertEqual('', $contact_form_data['redirect']); + } + } + +}