function UrlTest::testRenderAccess

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

Tests the renderAccess() method.

@covers ::renderAccess @dataProvider accessProvider @group legacy

Parameters

bool $access: The access value.

File

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

Class

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

Namespace

Drupal\Tests\Core

Code

public function testRenderAccess($access) : void {
    $element = [
        '#url' => Url::fromRoute('entity.node.canonical', [
            'node' => 3,
        ]),
    ];
    $this->container
        ->set('current_user', $this->createMock('Drupal\\Core\\Session\\AccountInterface'));
    $this->container
        ->set('access_manager', $this->getMockAccessManager($access));
    $this->expectDeprecation('Drupal\\Core\\Url::renderAccess() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3342977');
    $this->assertEquals($access, TestUrl::renderAccess($element));
}

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