You are here

public function PaymentExecutionPaymentMethodManagerTest::testGetOperationsProvider in Payment 8.2

@covers ::getOperationsProvider

File

tests/src/Unit/Plugin/Payment/Method/PaymentExecutionPaymentMethodManagerTest.php, line 111

Class

PaymentExecutionPaymentMethodManagerTest
@coversDefaultClass \Drupal\payment\Plugin\Payment\Method\PaymentExecutionPaymentMethodManager

Namespace

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

Code

public function testGetOperationsProvider() {
  $payment_method_id = $this
    ->randomMachineName();
  $payment_method = $this
    ->createMock(PaymentMethodInterface::class);
  $payment_method
    ->expects($this
    ->atLeastOnce())
    ->method('executePaymentAccess')
    ->with($this->account)
    ->willReturn(AccessResult::allowed());
  $payment_method_definitions = [
    $payment_method_id => [
      'id' => $payment_method_id,
    ],
  ];
  $this->paymentMethodManager
    ->expects($this
    ->atLeastOnce())
    ->method('getDefinitions')
    ->willReturn($payment_method_definitions);
  $this->paymentMethodManager
    ->expects($this
    ->atLeastOnce())
    ->method('createInstance')
    ->with($payment_method_id)
    ->willReturn($payment_method);
  $operations_provider = $this
    ->createMock(PluginOperationsProviderInterface::class);
  $this->paymentMethodManager
    ->expects($this
    ->atLeastOnce())
    ->method('getOperationsProvider')
    ->with($payment_method_id)
    ->willReturn($operations_provider);
  $this
    ->assertSame($operations_provider, $this->sut
    ->getOperationsProvider($payment_method_id));
}