You are here

public function GoogleSearchTest::testBuildLink in Freelinking 8.3

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

Asserts the failover functionality for the google search plugin.

File

tests/src/Unit/Plugin/freelinking/GoogleSearchTest.php, line 85

Class

GoogleSearchTest
Tests the google search plugin.

Namespace

Drupal\Tests\freelinking\Unit\Plugin\freelinking

Code

public function testBuildLink() {
  $expected = [
    '#type' => 'link',
    '#title' => 'Google Search Test Search',
    '#url' => Url::fromUri('https://google.com/search', [
      'absolute' => TRUE,
      'query' => [
        'q' => 'Test+Search',
        'hl' => 'en',
      ],
      'language' => NULL,
    ]),
    '#attributes' => [
      'title' => new TranslatableMarkup('Search google for the specified terms.', [], [], $this->translationInterfaceMock),
    ],
  ];
  $target = [
    'target' => 'google:Test Search|Test Search',
    'dest' => 'Test Search',
    'text' => 'Test Search',
    'language' => NULL,
  ];
  $this
    ->assertEquals($expected, $this->plugin
    ->buildLink($target));
}