public function LinkManipulatorTest::testSampleLink in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 tests/src/Functional/LinkManipulatorTest.php \Drupal\Tests\fillpdf\Functional\LinkManipulatorTest::testSampleLink()
Tests parsing a sample link.
File
- tests/
src/ Functional/ LinkManipulatorTest.php, line 82
Class
- LinkManipulatorTest
- @coversDefaultClass \Drupal\fillpdf\Service\FillPdfLinkManipulator
Namespace
Drupal\Tests\fillpdf\FunctionalCode
public function testSampleLink() {
$this
->uploadTestPdf('fillpdf_test_v3.pdf');
$form_id = $this
->getLatestFillPdfForm();
// Prepare a query with the sample flag and all kinds of (redundant)
// entity parameters set.
$query = [
'fid' => $form_id,
'entity_type' => 'user',
'entity_id' => 3,
'entity_ids' => [
'node:1',
'node:2',
],
'sample' => TRUE,
];
$url = Url::fromRoute('fillpdf.populate_pdf', [], [
'query' => $query,
]);
$context = $this->linkManipulator
->parseLink($url);
// Test 'fid' and 'sample' parameters are correctly set.
$this
->assertEquals($form_id, $context['fid']);
$this
->assertEquals(TRUE, $context['sample']);
// Make sure 'entity_ids' is empty and all other entity parameters stripped.
$this
->assertEmpty($context['entity_ids']);
$this
->assertArrayNotHasKey('entity_type', $context);
$this
->assertArrayNotHasKey('entity_id', $context);
}