function UrlTest::getMockAccessManager

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::getMockAccessManager()
  2. 8.9.x core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::getMockAccessManager()
  3. 10 core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::getMockAccessManager()

Creates a mock access manager for the access tests.

Parameters

bool $access: The access value.

\Drupal\Core\Session\AccountInterface|null $account: The account to test.

Return value

\Drupal\Core\Access\AccessManagerInterface|\PHPUnit\Framework\MockObject\MockObject

1 call to UrlTest::getMockAccessManager()
UrlTest::testAccessRouted in core/tests/Drupal/Tests/Core/UrlTest.php
Tests the access() method for routed URLs.

File

core/tests/Drupal/Tests/Core/UrlTest.php, line 803

Class

UrlTest
@coversDefaultClass \Drupal\Core\Url @group UrlTest

Namespace

Drupal\Tests\Core

Code

protected function getMockAccessManager($access, $account = NULL) {
    $access_manager = $this->createMock('Drupal\\Core\\Access\\AccessManagerInterface');
    $access_manager->expects($this->once())
        ->method('checkNamedRoute')
        ->with('entity.node.canonical', [
        'node' => 3,
    ], $account)
        ->willReturn($access);
    return $access_manager;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.