Commit 0745511b authored by catch's avatar catch

Issue #2563099 by morenstrat: Inject string translation service into ForumBreadcrumbBuilderBase

parent 19054281
......@@ -6,12 +6,12 @@ services:
- { name: backend_overridable }
forum.breadcrumb.node:
class: Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder
arguments: ['@entity.manager', '@config.factory', '@forum_manager']
arguments: ['@entity.manager', '@config.factory', '@forum_manager', '@string_translation']
tags:
- { name: breadcrumb_builder, priority: 1001 }
forum.breadcrumb.listing:
class: Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder
arguments: ['@entity.manager', '@config.factory', '@forum_manager']
arguments: ['@entity.manager', '@config.factory', '@forum_manager', '@string_translation']
tags:
- { name: breadcrumb_builder, priority: 1001 }
forum.index_storage:
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Link;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\forum\ForumManagerInterface;
/**
......@@ -50,11 +51,14 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
* The configuration factory.
* @param \Drupal\forum\ForumManagerInterface $forum_manager
* The forum manager service.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
*/
public function __construct(EntityManagerInterface $entity_manager, ConfigFactoryInterface $config_factory, ForumManagerInterface $forum_manager) {
public function __construct(EntityManagerInterface $entity_manager, ConfigFactoryInterface $config_factory, ForumManagerInterface $forum_manager, TranslationInterface $string_translation) {
$this->entityManager = $entity_manager;
$this->config = $config_factory->get('forum.settings');
$this->forumManager = $forum_manager;
$this->setStringTranslation($string_translation);
}
/**
......
......@@ -42,6 +42,7 @@ public function testConstructor() {
)
);
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
$translation_manager = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
// Make an object to test.
$builder = $this->getMockForAbstractClass(
......@@ -51,6 +52,7 @@ public function testConstructor() {
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
)
);
......@@ -58,6 +60,7 @@ public function testConstructor() {
$property_names = array(
'entityManager' => $entity_manager,
'forumManager' => $forum_manager,
'stringTranslation' => $translation_manager,
);
foreach ($property_names as $property_name => $property_value) {
$this->assertAttributeEquals(
......@@ -82,6 +85,10 @@ public function testConstructor() {
*/
public function testBuild() {
// Build all our dependencies, backwards.
$translation_manager = $this->getMockBuilder('Drupal\Core\StringTranslation\TranslationInterface')
->disableOriginalConstructor()
->getMock();
$forum_manager = $this->getMockBuilder('Drupal\forum\ForumManagerInterface')
->disableOriginalConstructor()
->getMock();
......@@ -125,6 +132,7 @@ public function testBuild() {
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
)
);
......
......@@ -46,6 +46,7 @@ public function testApplies($expected, $route_name = NULL, $parameter_map = arra
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$config_factory = $this->getConfigFactoryStub(array());
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
$translation_manager = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
// Make an object to test.
$builder = $this->getMockBuilder('Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder')
......@@ -53,6 +54,7 @@ public function testApplies($expected, $route_name = NULL, $parameter_map = arra
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
))
->setMethods(NULL)
->getMock();
......@@ -116,6 +118,10 @@ public function providerTestApplies() {
*/
public function testBuild() {
// Build all our dependencies, backwards.
$translation_manager = $this->getMockBuilder('Drupal\Core\StringTranslation\TranslationInterface')
->disableOriginalConstructor()
->getMock();
$prophecy = $this->prophesize('Drupal\taxonomy\Entity\Term');
$prophecy->label()->willReturn('Something');
$prophecy->id()->willReturn(1);
......@@ -177,6 +183,7 @@ public function testBuild() {
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
)
);
......
......@@ -51,6 +51,8 @@ public function testApplies($expected, $route_name = NULL, $parameter_map = arra
->method('checkNodeType')
->will($this->returnValue(TRUE));
$translation_manager = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
// Make an object to test.
$builder = $this->getMockBuilder('Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder')
->setConstructorArgs(
......@@ -58,6 +60,7 @@ public function testApplies($expected, $route_name = NULL, $parameter_map = arra
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
)
)
->setMethods(NULL)
......@@ -123,6 +126,10 @@ public function providerTestApplies() {
*/
public function testBuild() {
// Build all our dependencies, backwards.
$translation_manager = $this->getMockBuilder('Drupal\Core\StringTranslation\TranslationInterface')
->disableOriginalConstructor()
->getMock();
$prophecy = $this->prophesize('Drupal\taxonomy\Entity\Term');
$prophecy->label()->willReturn('Something');
$prophecy->id()->willReturn(1);
......@@ -185,6 +192,7 @@ public function testBuild() {
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
)
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment