function LocalActionDefaultTest::testGetTitleWithContext

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php \Drupal\Tests\Core\Menu\LocalActionDefaultTest::testGetTitleWithContext()
  2. 8.9.x core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php \Drupal\Tests\Core\Menu\LocalActionDefaultTest::testGetTitleWithContext()
  3. 11.x core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php \Drupal\Tests\Core\Menu\LocalActionDefaultTest::testGetTitleWithContext()

Tests the getTitle method with a translation context.

See also

\Drupal\Core\Menu\LocalTaskDefault::getTitle()

File

core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php, line 100

Class

LocalActionDefaultTest
@coversDefaultClass \Drupal\Core\Menu\LocalActionDefault @group Menu

Namespace

Drupal\Tests\Core\Menu

Code

public function testGetTitleWithContext() : void {
    $this->pluginDefinition['title'] = new TranslatableMarkup('Example', [], [
        'context' => 'context',
    ], $this->stringTranslation);
    $this->stringTranslation
        ->expects($this->once())
        ->method('translateString')
        ->with($this->pluginDefinition['title'])
        ->willReturn('Example translated with context');
    $this->setupLocalActionDefault();
    $this->assertEquals('Example translated with context', $this->localActionDefault
        ->getTitle());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.