You are here

protected function FeedsMockingTrait::getMockAccount in Feeds 8.3

Mocks an account object.

Parameters

array $perms: The account's permissions.

Return value

\Drupal\Core\Session\AccountInterface The mocked acount object.

File

tests/src/Traits/FeedsMockingTrait.php, line 84

Class

FeedsMockingTrait
Provides methods for mocking certain Feeds classes.

Namespace

Drupal\Tests\feeds\Traits

Code

protected function getMockAccount(array $perms = []) {
  $account = $this
    ->createMock(AccountInterface::class);
  if ($perms) {
    $map = [];
    foreach ($perms as $perm => $has) {
      $map[] = [
        $perm,
        $has,
      ];
    }
    $account
      ->expects($this
      ->any())
      ->method('hasPermission')
      ->will($this
      ->returnValueMap($map));
  }
  return $account;
}