public function NodeTest::testBuildLink in Freelinking 4.0.x
Same name and namespace in other branches
- 8.3 tests/src/Unit/Plugin/freelinking/NodeTest.php \Drupal\Tests\freelinking\Unit\Plugin\freelinking\NodeTest::testBuildLink()
Assert the buildLink method returns render array.
@dataProvider buildLinkProvider
Parameters
array $target: The target array.
array $expected: The expected render array.
bool $shouldFailover: Test logic to place container-dependent render array items.
File
- tests/
src/ Unit/ Plugin/ freelinking/ NodeTest.php, line 113
Class
- NodeTest
- Tests the nid plugin.
Namespace
Drupal\Tests\freelinking\Unit\Plugin\freelinkingCode
public function testBuildLink(array $target, array $expected, $shouldFailover = FALSE) {
$language = self::getDefaultLanguage();
if ($shouldFailover) {
$expected['#message'] = new TranslatableMarkup($expected['#message'], [
'@nid' => '2',
], [], $this->translationInterfaceMock);
}
else {
$expected['#url'] = Url::fromRoute('entity.node.canonical', [
'node' => 1,
], [
'language' => $language,
]);
$expected['#attributes']['title'] = new TranslatableMarkup('Click to view a local node', [], [], $this->translationInterfaceMock);
}
$this
->assertEquals($expected, $this->plugin
->buildLink($target));
}