public function FillPdfFormDeleteFormTest::testDeleteFormCancel in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 tests/src/Functional/FillPdfFormDeleteFormTest.php \Drupal\Tests\fillpdf\Functional\FillPdfFormDeleteFormTest::testDeleteFormCancel()
Tests the cancel link works.
File
- tests/
src/ Functional/ FillPdfFormDeleteFormTest.php, line 42
Class
- FillPdfFormDeleteFormTest
- @coversDefaultClass \Drupal\fillpdf\Form\FillPdfFormDeleteForm @group fillpdf
Namespace
Drupal\Tests\fillpdf\FunctionalCode
public function testDeleteFormCancel() {
$this
->uploadTestPdf('fillpdf_test_v3.pdf');
$fillpdf_form = FillPdfForm::load($this
->getLatestFillPdfForm());
// We're now on the edit form. Add an admin title.
$this
->assertSession()
->pageTextContains('New FillPDF form has been created.');
$admin_title = 'Test';
$this
->drupalPostForm(NULL, [
'admin_title[0][value]' => $admin_title,
], 'Save');
$this
->assertSession()
->pageTextContains("FillPDF Form {$admin_title} has been updated.");
// Now click 'Delete' but come back clicking 'Cancel'.
$this
->clickLink('Delete');
$this
->assertSession()
->pageTextContains("Are you sure you want to delete {$admin_title}?");
$this
->clickLink('Cancel');
$this
->assertSession()
->addressEquals($fillpdf_form
->toUrl('canonical'));
// Go to the overview form and repeat it all to see how it works with a
// destination added. There's only one FillPdfForm, so the first 'Delete'
// button is the right one.
$overview_url = Url::fromRoute('fillpdf.forms_admin');
$this
->drupalGet($overview_url);
$this
->clickLink('Delete');
$this
->assertSession()
->pageTextContains("Are you sure you want to delete {$admin_title}?");
$this
->clickLink('Cancel');
$this
->assertSession()
->addressEquals($overview_url);
// Now take the detour via edit. The edit form removes the original
// destination, so the cancelling user may come back.
$this
->drupalGet($overview_url);
$this
->clickLink('Edit');
$this
->clickLink('Delete');
$this
->assertSession()
->pageTextContains("Are you sure you want to delete {$admin_title}?");
$this
->clickLink('Cancel');
$this
->assertSession()
->addressEquals($fillpdf_form
->toUrl('canonical'));
}