You are here

public function PaymentMethodConfigurationAccessControlHandlerTest::testCheckAccessWithoutPermission in Payment 8.2

@covers ::checkAccess

File

tests/src/Unit/Entity/PaymentMethodConfiguration/PaymentMethodConfigurationAccessControlHandlerTest.php, line 102

Class

PaymentMethodConfigurationAccessControlHandlerTest
@coversDefaultClass \Drupal\payment\Entity\PaymentMethodConfiguration\PaymentMethodConfigurationAccessControlHandler

Namespace

Drupal\Tests\payment\Unit\Entity\PaymentMethodConfiguration

Code

public function testCheckAccessWithoutPermission() {
  $operation = $this
    ->randomMachineName();
  $account = $this
    ->createMock(AccountInterface::class);
  $account
    ->expects($this
    ->any())
    ->method('hasPermission')
    ->willReturn(FALSE);
  $payment_method_configuration = $this
    ->getMockPaymentMethodConfiguration();
  $class = new \ReflectionClass($this->sut);
  $method = $class
    ->getMethod('checkAccess');
  $method
    ->setAccessible(TRUE);
  $this
    ->assertFalse($method
    ->invokeArgs($this->sut, [
    $payment_method_configuration,
    $operation,
    $account,
  ])
    ->isAllowed());
}