public function ContactSitewideTest::deleteContactForms in Drupal 9
Same name and namespace in other branches
- 8 core/modules/contact/tests/src/Functional/ContactSitewideTest.php \Drupal\Tests\contact\Functional\ContactSitewideTest::deleteContactForms()
Deletes all forms.
1 call to ContactSitewideTest::deleteContactForms()
- ContactSitewideTest::testSiteWideContact in core/
modules/ contact/ tests/ src/ Functional/ ContactSitewideTest.php - Tests configuration options and the site-wide contact form.
File
- core/
modules/ contact/ tests/ src/ Functional/ ContactSitewideTest.php, line 593
Class
- ContactSitewideTest
- Tests site-wide contact form functionality.
Namespace
Drupal\Tests\contact\FunctionalCode
public 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
->assertSession()
->statusCodeEquals(403);
}
else {
$this
->drupalGet("admin/structure/contact/manage/{$id}/delete");
$this
->submitForm([], 'Delete');
$this
->assertSession()
->pageTextContains("The contact form {$contact_form->label()} has been deleted.");
$this
->assertNull(ContactForm::load($id), new FormattableMarkup('Form %contact_form not found', [
'%contact_form' => $contact_form
->label(),
]));
}
}
}