diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php index 29b51a2..e93b127 100644 --- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php @@ -7,7 +7,6 @@ namespace Drupal\Tests\Core\Menu; -use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Menu\ContextualLinkDefault; use Drupal\Tests\UnitTestCase; @@ -56,13 +55,6 @@ class ContextualLinkDefaultTest extends UnitTestCase { */ protected $stringTranslation; - /** - * The mocked route provider. - * - * @var \Drupal\Core\Routing\RouteProviderInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $routeProvider; - public static function getInfo() { return array( 'name' => 'Contextual links default.', @@ -75,16 +67,11 @@ protected function setUp() { parent::setUp(); $this->stringTranslation = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface'); - $this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface'); - - $container = new ContainerBuilder(); - $container->set('string_translation', $this->stringTranslation); - $container->set('router.route_provider', $this->routeProvider); - \Drupal::setContainer($container); } protected function setupContextualLinkDefault() { $this->contextualLinkDefault = new ContextualLinkDefault($this->config, $this->pluginId, $this->pluginDefinition); + $this->contextualLinkDefault->setTranslationManager($this->stringTranslation); } /** @@ -92,8 +79,8 @@ protected function setupContextualLinkDefault() { * * @see \Drupal\Core\Menu\LocalTaskDefault::getTitle() */ - public function testGetTitle() { - $this->pluginDefinition['title'] = 'Example'; + public function testGetTitle($title = 'Example') { + $this->pluginDefinition['title'] = $title; $this->stringTranslation->expects($this->once()) ->method('translate') ->with($this->pluginDefinition['title'], array(), array()) @@ -113,7 +100,7 @@ public function testGetTitleWithContext() { $this->pluginDefinition['title_context'] = 'context'; $this->stringTranslation->expects($this->once()) ->method('translate') - ->with($this->pluginDefinition['title'], array(), array('context' => 'context')) + ->with($this->pluginDefinition['title'], array(), array('context' => $this->pluginDefinition['title_context'])) ->will($this->returnValue('Example translated with context')); $this->setupContextualLinkDefault();