You are here

public function DrupalOrgTest::testBuildLink in Freelinking 8.3

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

Asserts that buildLink returns appropriate render array.

A data provider is not used for this test because Guzzle mocking is a bit weird and unorthodox.

File

tests/src/Unit/Plugin/freelinking/DrupalOrgTest.php, line 103

Class

DrupalOrgTest
Tests the drupalorg plugin.

Namespace

Drupal\Tests\freelinking\Unit\Plugin\freelinking

Code

public function testBuildLink() {
  $plugin = $this
    ->getPlugin();
  $target = [
    'dest' => 'freelinking',
    'indicator' => 'drupalproject',
    'language' => NULL,
    'text' => '',
  ];
  $expected = [
    '#type' => 'link',
    '#title' => new TranslatableMarkup('Drupal.org: “@title”', [
      '@title' => 'Freelinking',
    ], [], $this->translationInterfaceMock),
    '#url' => Url::fromUri('https://drupal.org/project/freelinking', [
      'absolute' => TRUE,
      'language' => NULL,
    ]),
    '#attributes' => [
      'title' => new TranslatableMarkup('Click to view on drupal.org.', [], [], $this->translationInterfaceMock),
    ],
  ];

  // Assert that 200 Response with title.
  $this
    ->assertEquals($expected, $plugin
    ->buildLink($target));
}