You are here

public function WikiTest::testBuildLink in Freelinking 4.0.x

Same name and namespace in other branches
  1. 8.3 tests/src/Unit/Plugin/freelinking/WikiTest.php \Drupal\Tests\freelinking\Unit\Plugin\freelinking\WikiTest::testBuildLink()

Asserts that buildLink is functional.

@dataProvider buildLinkProvider

Parameters

string $indicator: The wiki to test.

string $destination: The destination string.

string $langcode: The language code to test.

string $expectedUrl: The expected URL.

File

tests/src/Unit/Plugin/freelinking/WikiTest.php, line 88

Class

WikiTest
Test the freelinking wiki plugin.

Namespace

Drupal\Tests\freelinking\Unit\Plugin\freelinking

Code

public function testBuildLink($indicator, $destination, $langcode, $expectedUrl) {
  $language = new Language([
    'id' => $langcode,
  ]);
  $expected = [
    '#type' => 'link',
    '#title' => 'Test Wiki',
    '#url' => Url::fromUri($expectedUrl, [
      'language' => $language,
      'absolute' => TRUE,
    ]),
    '#attributes' => [
      'title' => new TranslatableMarkup('Click to view a wiki page.', [], [], $this->translationInterfaceMock),
    ],
  ];
  $target = [
    'indicator' => $indicator,
    'text' => 'Test Wiki',
    'target' => $indicator . ':' . $destination,
    'dest' => $destination,
    'language' => $language,
  ];
  $plugin = $this
    ->getPlugin();
  $this
    ->assertEquals($expected, $plugin
    ->buildLink($target));
}