public function BreadcrumbManagerTest::testBuildWithMultipleApplyingBuilders in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php \Drupal\Tests\Core\Breadcrumb\BreadcrumbManagerTest::testBuildWithMultipleApplyingBuilders()
Tests multiple breadcrumb builder with different priority.
File
- core/
tests/ Drupal/ Tests/ Core/ Breadcrumb/ BreadcrumbManagerTest.php, line 117 - Contains \Drupal\Tests\Core\Breadcrumb\BreadcrumbManagerTest.
Class
- BreadcrumbManagerTest
- @coversDefaultClass \Drupal\Core\Breadcrumb\BreadcrumbManager @group Breadcrumb
Namespace
Drupal\Tests\Core\BreadcrumbCode
public function testBuildWithMultipleApplyingBuilders() {
$builder1 = $this
->getMock('Drupal\\Core\\Breadcrumb\\BreadcrumbBuilderInterface');
$builder1
->expects($this
->never())
->method('applies');
$builder1
->expects($this
->never())
->method('build');
$builder2 = $this
->getMock('Drupal\\Core\\Breadcrumb\\BreadcrumbBuilderInterface');
$links2 = array(
'<a href="/example2">Test2</a>',
);
$this->breadcrumb
->setLinks($links2);
$this->breadcrumb
->addCacheContexts([
'baz',
])
->addCacheTags([
'qux',
]);
$builder2
->expects($this
->once())
->method('applies')
->will($this
->returnValue(TRUE));
$builder2
->expects($this
->once())
->method('build')
->willReturn($this->breadcrumb);
$route_match = $this
->getMock('Drupal\\Core\\Routing\\RouteMatchInterface');
$this->moduleHandler
->expects($this
->once())
->method('alter')
->with('system_breadcrumb', $this->breadcrumb, $route_match, array(
'builder' => $builder2,
));
$this->breadcrumbManager
->addBuilder($builder1, 0);
$this->breadcrumbManager
->addBuilder($builder2, 10);
$breadcrumb = $this->breadcrumbManager
->build($route_match);
$this
->assertEquals($links2, $breadcrumb
->getLinks());
$this
->assertEquals([
'baz',
], $breadcrumb
->getCacheContexts());
$this
->assertEquals([
'qux',
], $breadcrumb
->getCacheTags());
$this
->assertEquals(Cache::PERMANENT, $breadcrumb
->getCacheMaxAge());
}