You are here

function ContactSitewideTest::deleteContactForms in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/contact/src/Tests/ContactSitewideTest.php \Drupal\contact\Tests\ContactSitewideTest::deleteContactForms()

Deletes all forms.

1 call to ContactSitewideTest::deleteContactForms()
ContactSitewideTest::testSiteWideContact in core/modules/contact/src/Tests/ContactSitewideTest.php
Tests configuration options and the site-wide contact form.

File

core/modules/contact/src/Tests/ContactSitewideTest.php, line 432
Contains \Drupal\contact\Tests\ContactSitewideTest.

Class

ContactSitewideTest
Tests site-wide contact form functionality.

Namespace

Drupal\contact\Tests

Code

function deleteContactForms() {
  $contact_forms = ContactForm::loadMultiple();
  foreach ($contact_forms as $id => $contact_form) {
    if ($id == 'personal') {

      // Personal form could not be deleted.
      $this
        ->drupalGet("admin/structure/contact/manage/{$id}/delete");
      $this
        ->assertResponse(403);
    }
    else {
      $this
        ->drupalPostForm("admin/structure/contact/manage/{$id}/delete", array(), t('Delete'));
      $this
        ->assertRaw(t('The contact form %label has been deleted.', array(
        '%label' => $contact_form
          ->label(),
      )));
      $this
        ->assertFalse(ContactForm::load($id), format_string('Form %contact_form not found', array(
        '%contact_form' => $contact_form
          ->label(),
      )));
    }
  }
}