ContactUpdateTest.php in Drupal 8
File
core/modules/contact/tests/src/Functional/Update/ContactUpdateTest.php
View source
<?php
namespace Drupal\Tests\contact\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class ContactUpdateTest extends UpdatePathTestBase {
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
];
}
public function testPostUpdateContactFormFields() {
$config_factory = \Drupal::configFactory();
$contact_forms = $config_factory
->listAll('contact.form.');
$this
->assertGreaterThan(0, 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.');
}
$this
->runUpdates();
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']);
}
}
}