You are here

public function CompletePaymentTest::testExecute in Payment 8.2

@covers ::execute

File

tests/src/Unit/Controller/CompletePaymentTest.php, line 37

Class

CompletePaymentTest
@coversDefaultClass \Drupal\payment\Controller\CompletePayment

Namespace

Drupal\Tests\payment\Unit\Controller

Code

public function testExecute() {
  $response = $this
    ->getMockBuilder(Response::class)
    ->disableOriginalConstructor()
    ->getMock();
  $completion_response = $this
    ->createMock(ResponseInterface::class);
  $completion_response
    ->expects($this
    ->atLeastOnce())
    ->method('getResponse')
    ->willReturn($response);
  $execution_result = $this
    ->createMock(OperationResultInterface::class);
  $execution_result
    ->expects($this
    ->atLeastOnce())
    ->method('getCompletionResponse')
    ->willReturn($completion_response);
  $payment_method = $this
    ->createMock(PaymentMethodInterface::class);
  $payment_method
    ->expects($this
    ->atLeastOnce())
    ->method('getPaymentExecutionResult')
    ->willReturn($execution_result);
  $payment = $this
    ->createMock(PaymentInterface::class);
  $payment
    ->expects($this
    ->atLeastOnce())
    ->method('getPaymentMethod')
    ->willReturn($payment_method);
  $this
    ->assertSame($response, $this->sut
    ->execute($payment));
}