You are here

function CurrencyLocaleAccessControlHandlerTest::testCheckAccess in Currency 8.3

@covers ::checkAccess

@dataProvider providerTestCheckAccess

File

tests/src/Unit/Entity/CurrencyLocale/CurrencyLocaleAccessControlHandlerTest.php, line 95

Class

CurrencyLocaleAccessControlHandlerTest
@coversDefaultClass Drupal\currency\Entity\CurrencyLocale\CurrencyLocaleAccessControlHandler

Namespace

Drupal\Tests\currency\Unit\Entity\CurrencyLocale

Code

function testCheckAccess($expected_value, $operation, $has_permission, $permission, $locale = NULL) {
  $account = $this
    ->createMock(AccountInterface::class);
  $account
    ->expects($this
    ->any())
    ->method('hasPermission')
    ->with($permission)
    ->willReturn((bool) $has_permission);
  $currency_locale = $this
    ->createMock(CurrencyLocaleInterface::class);
  $currency_locale
    ->expects($this
    ->any())
    ->method('getLocale')
    ->willReturn($locale);
  $this->moduleHandler
    ->expects($this
    ->any())
    ->method('invokeAll')
    ->willReturn([]);
  $method = new \ReflectionMethod($this->sut, 'checkAccess');
  $method
    ->setAccessible(TRUE);
  $this
    ->assertSame($expected_value, $method
    ->invoke($this->sut, $currency_locale, $operation, $account)
    ->isAllowed());
}