You are here

public function BuiltinTest::testBuildLink in Freelinking 8.3

Same name and namespace in other branches
  1. 4.0.x 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 104

Class

BuiltinTest
Tests the freelinking builtin plugin.

Namespace

Drupal\Tests\freelinking\Unit\Plugin\freelinking

Code

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));
}