public function EntityAccessCheckTest::testAccess

Tests the method for checking access to routes.

File

drupal/core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php, line 58
Contains \Drupal\Tests\Core\Entity\EntityAccessCheckTest.

Class

EntityAccessCheckTest
Tests the entity access controller.

Namespace

Drupal\Tests\Core\Entity

Code

public function testAccess() {
  $route = new Route('/foo', array(), array(
    '_entity_access' => 'node.update',
  ));
  $request = new Request();
  $node = $this
    ->getMockBuilder('Drupal\\node\\Plugin\\Core\\Entity\\Node')
    ->disableOriginalConstructor()
    ->getMock();
  $node
    ->expects($this
    ->any())
    ->method('access')
    ->will($this
    ->returnValue(TRUE));
  $access_check = new EntityAccessCheck();
  $request->attributes
    ->set('node', $node);
  $access = $access_check
    ->access($route, $request);
  $this
    ->assertEquals(TRUE, $access);
}