public function UserTest::testBuildLink in Freelinking 4.0.x
Same name and namespace in other branches
- 8.3 tests/src/Unit/Plugin/freelinking/UserTest.php \Drupal\Tests\freelinking\Unit\Plugin\freelinking\UserTest::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/ UserTest.php, line 122
Class
- UserTest
- Tests the user plugin.
Namespace
Drupal\Tests\freelinking\Unit\Plugin\freelinkingCode
public function testBuildLink(array $target, array $expected, $shouldFailover = FALSE) {
if ($shouldFailover) {
$defaultMessage = $expected['#message'];
$expected['#message'] = new TranslatableMarkup($defaultMessage, [
'%user' => '2',
], [], $this->translationInterfaceMock);
}
else {
$expected['#url'] = Url::fromRoute('entity.user.canonical', [
'user' => 1,
], [
'language' => NULL,
]);
$expected['#attributes']['title'] = new TranslatableMarkup('Click to view user profile.', [], [], $this->translationInterfaceMock);
}
$this
->assertEquals($expected, $this->plugin
->buildLink($target));
}