You are here

public function BasicTest::testDoCapturePaymentAccess in Payment 8.2

@covers ::doCapturePaymentAccess

@dataProvider providerDoCapturePaymentAccess

File

tests/src/Unit/Plugin/Payment/Method/BasicTest.php, line 182

Class

BasicTest
@coversDefaultClass \Drupal\payment\Plugin\Payment\Method\Basic

Namespace

Drupal\Tests\payment\Unit\Plugin\Payment\Method

Code

public function testDoCapturePaymentAccess($expected, $capture, $current_status_id, $capture_status_id) {
  $this->pluginDefinition['capture'] = $capture;
  $this->pluginDefinition['capture_status_id'] = $capture_status_id;
  $this->sut = new Basic([], '', $this->pluginDefinition, $this->moduleHandler, $this->eventDispatcher, $this->token, $this->paymentStatusManager);
  $capture_payment_status = $this
    ->createMock(PaymentStatusInterface::class);
  $capture_payment_status
    ->expects($this
    ->any())
    ->method('getPluginId')
    ->willReturn($current_status_id);
  $capture_payment_status = $this
    ->createMock(PaymentStatusInterface::class);
  $capture_payment_status
    ->expects($this
    ->any())
    ->method('getPluginId')
    ->willReturn($current_status_id);
  $payment = $this
    ->createMock(PaymentInterface::class);
  $payment
    ->expects($this
    ->any())
    ->method('getPaymentStatus')
    ->willReturn($capture_payment_status);
  $this->sut
    ->setPayment($payment);
  $account = $this
    ->createMock(AccountInterface::class);
  $method = new \ReflectionMethod($this->sut, 'doCapturePaymentAccess');
  $method
    ->setAccessible(TRUE);
  $this
    ->assertSame($expected, $method
    ->invoke($this->sut, $account));
}