You are here

public function ContextualLinkDefaultTest::testGetTitleWithContext in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php \Drupal\Tests\Core\Menu\ContextualLinkDefaultTest::testGetTitleWithContext()
  2. 9 core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php \Drupal\Tests\Core\Menu\ContextualLinkDefaultTest::testGetTitleWithContext()

@covers ::getTitle

File

core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php, line 81

Class

ContextualLinkDefaultTest
@group Menu @coversDefaultClass \Drupal\Core\Menu\ContextualLinkDefault

Namespace

Drupal\Tests\Core\Menu

Code

public function testGetTitleWithContext() {
  $title = 'Example';
  $this->pluginDefinition['title'] = new TranslatableMarkup($title, [], [
    'context' => 'context',
  ], $this->stringTranslation);
  $this->stringTranslation
    ->expects($this
    ->once())
    ->method('translateString')
    ->with($this->pluginDefinition['title'])
    ->will($this
    ->returnValue('Example translated with context'));
  $this
    ->setupContextualLinkDefault();
  $this
    ->assertEquals('Example translated with context', $this->contextualLinkDefault
    ->getTitle());
}