public function HandlePdfControllerTest::testRedirectAction in FillPDF 8.4
Same name and namespace in other branches
- 5.0.x tests/src/Functional/HandlePdfControllerTest.php \Drupal\Tests\fillpdf\Functional\HandlePdfControllerTest::testRedirectAction()
Tests RedirectAction.
File
- tests/
src/ Functional/ HandlePdfControllerTest.php, line 103
Class
- HandlePdfControllerTest
- @coversDefaultClass \Drupal\fillpdf\Controller\HandlePdfController
Namespace
Drupal\Tests\fillpdf\FunctionalCode
public function testRedirectAction() {
$this
->uploadTestPdf('fillpdf_test_v3.pdf');
$form_id = $this
->getLatestFillPdfForm();
$edit = [
'scheme' => 'public',
'destination_redirect[value]' => TRUE,
];
$this
->drupalPostForm("admin/structure/fillpdf/{$form_id}", $edit, 'Save');
$fid_before = $this
->getLastFileId();
$fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [
'query' => [
'fid' => $form_id,
'sample' => 1,
],
]);
$this
->drupalGet($fillpdf_route);
$fid_after = $this
->getLastFileId();
// Make sure the PDF file has been saved.
$this
->assertEquals($fid_before + 1, $fid_after);
// Make sure we have been redirected to the PDF.
$this
->assertSession()
->statusCodeEquals(200);
$maybe_pdf = $this
->getSession()
->getPage()
->getContent();
static::assertEquals('application/pdf', $this
->getMimeType($maybe_pdf), "The file has the correct MIME type.");
}