function ForumListingBreadcrumbBuilderTest::testApplies

Same name in other branches
  1. 9 core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php \Drupal\Tests\forum\Unit\Breadcrumb\ForumListingBreadcrumbBuilderTest::testApplies()
  2. 10 core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php \Drupal\Tests\forum\Unit\Breadcrumb\ForumListingBreadcrumbBuilderTest::testApplies()
  3. 11.x core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php \Drupal\Tests\forum\Unit\Breadcrumb\ForumListingBreadcrumbBuilderTest::testApplies()

Tests ForumListingBreadcrumbBuilder::applies().

@dataProvider providerTestApplies @covers ::applies

Parameters

bool $expected: ForumListingBreadcrumbBuilder::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/ForumListingBreadcrumbBuilderTest.php, line 46

Class

ForumListingBreadcrumbBuilderTest
@coversDefaultClass \Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder @group forum

Namespace

Drupal\Tests\forum\Unit\Breadcrumb

Code

public function testApplies($expected, $route_name = NULL, $parameter_map = []) {
    // Make some test doubles.
    $entity_manager = $this->createMock('Drupal\\Core\\Entity\\EntityManagerInterface');
    $config_factory = $this->getConfigFactoryStub([]);
    $forum_manager = $this->createMock('Drupal\\forum\\ForumManagerInterface');
    $translation_manager = $this->createMock('Drupal\\Core\\StringTranslation\\TranslationInterface');
    // Make an object to test.
    $builder = $this->getMockBuilder('Drupal\\forum\\Breadcrumb\\ForumListingBreadcrumbBuilder')
        ->setConstructorArgs([
        $entity_manager,
        $config_factory,
        $forum_manager,
        $translation_manager,
    ])
        ->setMethods(NULL)
        ->getMock();
    $route_match = $this->createMock('Drupal\\Core\\Routing\\RouteMatchInterface');
    $route_match->expects($this->once())
        ->method('getRouteName')
        ->will($this->returnValue($route_name));
    $route_match->expects($this->any())
        ->method('getParameter')
        ->will($this->returnValueMap($parameter_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.