You are here

public function LinkManipulatorTest::testLinkExceptions in FillPDF 5.0.x

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/LinkManipulatorTest.php \Drupal\Tests\fillpdf\Functional\LinkManipulatorTest::testLinkExceptions()

Tests handling of a non-existing FillPdfForm ID.

File

tests/src/Functional/LinkManipulatorTest.php, line 51

Class

LinkManipulatorTest
@coversDefaultClass \Drupal\fillpdf\Service\FillPdfLinkManipulator

Namespace

Drupal\Tests\fillpdf\Functional

Code

public function testLinkExceptions() {

  // Hit the generation route with no query string set.
  $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], []);
  $this
    ->drupalGet($fillpdf_route);

  // Hit the generation route with no fid set.
  $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [
    'query' => [
      'sample' => 1,
    ],
  ]);
  $this
    ->drupalGet($fillpdf_route);

  // Ensure the exception is converted to an error and access is denied.
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->assertSession()
    ->pageTextContains("No FillPDF Form was specified in the query string, so failing.");

  // Hit the generation route with a non-existing fid set.
  $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [
    'query' => [
      'fid' => 1234,
    ],
  ]);
  $this
    ->drupalGet($fillpdf_route);

  // Ensure the exception is converted to an error and access is denied.
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->assertSession()
    ->pageTextContains("The requested FillPDF Form doesn't exist, so failing.");
}