You are here

public function PathAliasSearchTest::testBuildLink in Freelinking 8.3

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

Asserts that buildLink is functional for search failover.

File

tests/src/Unit/Plugin/freelinking/PathAliasSearchTest.php, line 84

Class

PathAliasSearchTest
Tests the path_alias plugin.

Namespace

Drupal\Tests\freelinking\Unit\Plugin\freelinking

Code

public function testBuildLink() {
  $target = [
    'text' => 'A valid path alias',
    'dest' => 'invalidalias',
    'target' => 'alias:invalidalias|A valid path alias',
    'language' => NULL,
  ];
  $plugin = $this
    ->getPlugin('search');
  $expected = [
    '#type' => 'link',
    '#title' => 'A valid path alias',
    '#url' => Url::fromUri('base:search', [
      'query' => [
        'keys' => '/invalidalias',
      ],
      'language' => NULL,
    ]),
    '#attributes' => [
      'title' => new TranslatableMarkup('Click to view a local node.', [], [], $this->translationInterfaceMock),
    ],
  ];
  $this
    ->assertEquals($expected, $plugin
    ->buildLink($target));
}