public function BuiltinTest::testBuildLink in Freelinking 4.0.x
Same name and namespace in other branches
- 8.3 tests/src/Unit/Plugin/freelinking/BuiltinTest.php \Drupal\Tests\freelinking\Unit\Plugin\freelinking\BuiltinTest::testBuildLink()
Asserts that buildLink is functional for all patterns.
@dataProvider buildLinkProvider
Parameters
string $indicator: The indicator to test.
string $dest: The target destination text.
bool $isAuthenticated: The return value for isAuthenticated method.
string $text: The expected text to find.
File
- tests/
src/ Unit/ Plugin/ freelinking/ BuiltinTest.php, line 107
Class
- BuiltinTest
- Tests the freelinking builtin plugin.
Namespace
Drupal\Tests\freelinking\Unit\Plugin\freelinkingCode
public function testBuildLink($indicator, $dest, $isAuthenticated, $text) {
$accountProphet = $this
->prophesize('\\Drupal\\Core\\Session\\AccountProxyInterface');
$accountProphet
->isAuthenticated()
->willReturn($isAuthenticated);
$target = [
'indicator' => $indicator,
'target' => '[[' . $indicator . '|' . $dest . ']]',
'dest' => $dest,
'text' => NULL,
];
$expected = [
'#markup' => $text,
];
$plugin = new Builtin($this->configuration, $this->id, $this->definition, $accountProphet
->reveal());
$this
->assertEquals($expected, $plugin
->buildLink($target));
}