Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / contact / src / Tests / Update / ContactUpdateTest.php
1 <?php
2
3 namespace Drupal\contact\Tests\Update;
4
5 use Drupal\system\Tests\Update\UpdatePathTestBase;
6
7 /**
8  * Tests contact update path.
9  *
10  * @group contact
11  */
12 class ContactUpdateTest extends UpdatePathTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   protected function setDatabaseDumpFiles() {
18     $this->databaseDumpFiles = [
19       __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
20     ];
21   }
22
23   /**
24    * Tests contact_form updates.
25    *
26    * @see contact_post_update_add_message_redirect_field_to_contact_form()
27    */
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.');
38     }
39
40     // Run updates.
41     $this->runUpdates();
42
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']);
50     }
51   }
52
53 }