You are here

function PaymentCaptureFormTest::testSubmitFormWithoutCompletionResponse in Payment 8.2

@covers ::submitForm

File

tests/src/Unit/Entity/Payment/PaymentCaptureFormTest.php, line 156

Class

PaymentCaptureFormTest
@coversDefaultClass \Drupal\payment\Entity\Payment\PaymentCaptureForm

Namespace

Drupal\Tests\payment\Unit\Entity\Payment

Code

function testSubmitFormWithoutCompletionResponse() {
  $operation_result = $this
    ->createMock(OperationResultInterface::class);
  $operation_result
    ->expects($this
    ->atLeastOnce())
    ->method('isCompleted')
    ->willReturn(TRUE);
  $payment_method = $this
    ->createMock(PaymentMethodCapturePaymentInterface::class);
  $payment_method
    ->expects($this
    ->once())
    ->method('capturePayment')
    ->willReturn($operation_result);
  $url = new Url($this
    ->randomMachineName());
  $this->payment
    ->expects($this
    ->atLeastOnce())
    ->method('getPaymentMethod')
    ->willReturn($payment_method);
  $this->payment
    ->expects($this
    ->atLeastOnce())
    ->method('toUrl')
    ->with('canonical')
    ->willReturn($url);
  $form = [];
  $form_state = $this
    ->createMock(FormStateInterface::class);
  $form_state
    ->expects($this
    ->atLeastOnce())
    ->method('setRedirectUrl')
    ->with($url);
  $this->sut
    ->submitForm($form, $form_state);
}