use Drupal\Core\Cache\Cache;
use Drupal\Core\Link;
use Drupal\Core\Access\AccessResultAllowed;
+use Drupal\Core\Path\PathMatcherInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\Core\Url;
use Drupal\Core\Utility\LinkGeneratorInterface;
*/
protected $currentPath;
+ /**
+ * The mocked path matcher service.
+ *
+ * @var \Drupal\Core\Path\PathMatcherInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $pathMatcher;
+
/**
* {@inheritdoc}
*
->disableOriginalConstructor()
->getMock();
+ $this->pathMatcher = $this->getMock(PathMatcherInterface::class);
+
$this->builder = new TestPathBasedBreadcrumbBuilder(
$this->context,
$this->accessManager,
$config_factory,
$this->titleResolver,
$this->currentUser,
- $this->currentPath
+ $this->currentPath,
+ $this->pathMatcher
);
$this->builder->setStringTranslation($this->getStringTranslationStub());
* @covers ::build
*/
public function testBuildOnFrontpage() {
- $this->context->expects($this->once())
- ->method('getPathInfo')
- ->will($this->returnValue('/'));
+ $this->pathMatcher->expects($this->once())
+ ->method('isFrontPage')
+ ->willReturn(TRUE);
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([], $breadcrumb->getLinks());
$this->requestMatcher->expects($this->exactly(1))
->method('matchRequest')
- ->will($this->returnCallback(function(Request $request) use ($route_1) {
+ ->will($this->returnCallback(function (Request $request) use ($route_1) {
if ($request->getPathInfo() == '/example') {
return [
RouteObjectInterface::ROUTE_NAME => 'example',
$this->requestMatcher->expects($this->exactly(2))
->method('matchRequest')
- ->will($this->returnCallback(function(Request $request) use ($route_1, $route_2) {
+ ->will($this->returnCallback(function (Request $request) use ($route_1, $route_2) {
if ($request->getPathInfo() == '/example/bar') {
return [
RouteObjectInterface::ROUTE_NAME => 'example_bar',
$this->requestMatcher->expects($this->exactly(1))
->method('matchRequest')
- ->will($this->returnCallback(function(Request $request) use ($route_1) {
+ ->will($this->returnCallback(function (Request $request) use ($route_1) {
if ($request->getPathInfo() == '/user/1') {
return [
RouteObjectInterface::ROUTE_NAME => 'user_page',