function EntityAccessCheckTest::createRouteMatchForObject

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php \Drupal\Tests\Core\Entity\EntityAccessCheckTest::createRouteMatchForObject()
  2. 10 core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php \Drupal\Tests\Core\Entity\EntityAccessCheckTest::createRouteMatchForObject()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php \Drupal\Tests\Core\Entity\EntityAccessCheckTest::createRouteMatchForObject()

Wrap any object with a route match, and return that.

Parameters

object $object: Any object, including prophesized mocks based on interfaces.

Return value

\Drupal\Core\Routing\RouteMatchInterface A prophesized RouteMatchInterface.

2 calls to EntityAccessCheckTest::createRouteMatchForObject()
EntityAccessCheckTest::testAccessWithDifferentRouteParameters in core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php
@covers ::access
EntityAccessCheckTest::testAccessWithTypePlaceholder in core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php
@covers ::access

File

core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php, line 119

Class

EntityAccessCheckTest
Unit test of entity access checking system.

Namespace

Drupal\Tests\Core\Entity

Code

private function createRouteMatchForObject(\stdClass $object) {
    $route_match = $this->prophesize(RouteMatchInterface::class);
    $route_match->getRawParameters()
        ->willReturn(new ParameterBag([
        'entity_type' => 'node',
        'var_name' => 1,
    ]));
    $route_match->getParameters()
        ->willReturn(new ParameterBag([
        'entity_type' => 'node',
        'var_name' => $object,
    ]));
    return $route_match->reveal();
}

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