public function DrupalOrgTest::testBuildLink in Freelinking 4.0.x
Same name and namespace in other branches
- 8.3 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 106
Class
- DrupalOrgTest
- Tests the drupalorg plugin.
Namespace
Drupal\Tests\freelinking\Unit\Plugin\freelinkingCode
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));
}