You are here

protected function EntityAccessControlHandlerTest::buildMockUser in Entity API 8

Builds a mock user.

Parameters

int $uid: The user ID.

string $permission: The permission to grant.

Return value

\Prophecy\Prophecy\ObjectProphecy The user mock.

2 calls to EntityAccessControlHandlerTest::buildMockUser()
EntityAccessControlHandlerTest::accessProvider in tests/src/Unit/EntityAccessControlHandlerTest.php
Data provider for testAccess().
EntityAccessControlHandlerTest::createAccessProvider in tests/src/Unit/EntityAccessControlHandlerTest.php
Data provider for testCreateAccess().

File

tests/src/Unit/EntityAccessControlHandlerTest.php, line 243

Class

EntityAccessControlHandlerTest
@coversDefaultClass \Drupal\entity\EntityAccessControlHandler @group entity

Namespace

Drupal\Tests\entity\Unit

Code

protected function buildMockUser($uid, $permission) {
  $account = $this
    ->prophesize(AccountInterface::class);
  $account
    ->id()
    ->willReturn($uid);
  $account
    ->hasPermission($permission)
    ->willReturn(TRUE);
  $account
    ->hasPermission(Argument::any())
    ->willReturn(FALSE);
  return $account;
}