function ForumNodeBreadcrumbBuilderTest::testApplies
Same name in other branches
- 9 core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php \Drupal\Tests\forum\Unit\Breadcrumb\ForumNodeBreadcrumbBuilderTest::testApplies()
- 8.9.x core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php \Drupal\Tests\forum\Unit\Breadcrumb\ForumNodeBreadcrumbBuilderTest::testApplies()
- 11.x core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php \Drupal\Tests\forum\Unit\Breadcrumb\ForumNodeBreadcrumbBuilderTest::testApplies()
Tests ForumNodeBreadcrumbBuilder::applies().
@dataProvider providerTestApplies @covers ::applies
Parameters
bool $expected: ForumNodeBreadcrumbBuilder::applies() expected result.
string|null $route_name: (optional) A route name.
array $parameter_map: (optional) An array of parameter names and values.
File
-
core/
modules/ forum/ tests/ src/ Unit/ Breadcrumb/ ForumNodeBreadcrumbBuilderTest.php, line 51
Class
- ForumNodeBreadcrumbBuilderTest
- @coversDefaultClass \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder @group forum @group legacy
Namespace
Drupal\Tests\forum\Unit\BreadcrumbCode
public function testApplies(bool $expected, ?string $route_name = NULL, array $parameter_map = []) : void {
// Make some test doubles.
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$config_factory = $this->getConfigFactoryStub([]);
$map = [];
if ($parameter_map) {
foreach ($parameter_map as $parameter) {
$map[] = [
$parameter[0],
$parameter[1] === TRUE ? $this->getMockBuilder(Node::class)
->disableOriginalConstructor()
->getMock() : $parameter[1],
];
}
}
$forum_manager = $this->createMock('Drupal\\forum\\ForumManagerInterface');
$forum_manager->expects($this->any())
->method('checkNodeType')
->willReturn(TRUE);
$translation_manager = $this->createMock('Drupal\\Core\\StringTranslation\\TranslationInterface');
// Make an object to test.
$builder = new ForumNodeBreadcrumbBuilder($entity_type_manager, $config_factory, $forum_manager, $translation_manager);
$route_match = $this->createMock('Drupal\\Core\\Routing\\RouteMatchInterface');
$route_match->expects($this->once())
->method('getRouteName')
->willReturn($route_name);
$route_match->expects($this->any())
->method('getParameter')
->willReturnMap($map);
$this->assertEquals($expected, $builder->applies($route_match));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.