You are here

public function FillPdfOverviewFormTest::testOverviewFormLinks in FillPDF 5.0.x

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

Tests the overview form's operation links.

File

tests/src/Functional/FillPdfOverviewFormTest.php, line 48

Class

FillPdfOverviewFormTest
@coversDefaultClass \Drupal\fillpdf\Form\FillPdfOverviewForm @group fillpdf

Namespace

Drupal\Tests\fillpdf\Functional

Code

public function testOverviewFormLinks() {
  $this
    ->uploadTestPdf('fillpdf_test_v3.pdf');

  // Set the administrative title and check if it has been successfully set.
  $admin_title = 'Example form';
  $this
    ->drupalPostForm(NULL, [
    'admin_title[0][value]' => $admin_title,
  ], self::OP_SAVE);
  $this
    ->assertSession()
    ->pageTextContains("FillPDF Form {$admin_title} has been updated.");
  $this
    ->assertSession()
    ->fieldValueEquals('edit-admin-title-0-value', $admin_title);

  // Go back to the overview page.
  $this
    ->drupalGet('admin/structure/fillpdf');

  // Check if the administrative title appears in the view.
  $this
    ->assertSession()
    ->pageTextContains($admin_title);

  // Check hook_entity_operation_alter(). Only the altered link should exist.
  $this
    ->assertSession()
    ->linkExistsExact('Import configuration test');
  $this
    ->assertSession()
    ->linkNotExistsExact('Import configuration');

  // Check hook_entity_operation(). Both links should exist.
  $this
    ->assertSession()
    ->linkExistsExact('Export configuration test');
  $this
    ->assertSession()
    ->linkExistsExact('Export configuration');
}