You are here

public function ListPaymentMethodsTest::testExecute in Payment 8.2

@covers ::execute

File

tests/src/Unit/Controller/ListPaymentMethodsTest.php, line 71

Class

ListPaymentMethodsTest
@coversDefaultClass \Drupal\payment\Controller\ListPaymentMethods

Namespace

Drupal\Tests\payment\Unit\Controller

Code

public function testExecute() {
  $plugin_id_a = $this
    ->randomMachineName();
  $plugin_id_b = $this
    ->randomMachineName();
  $definitions = [
    $plugin_id_a => [
      'active' => TRUE,
      'class' => $this
        ->getMockClass(PaymentMethodInterface::class),
      'label' => $this
        ->randomMachineName(),
    ],
    $plugin_id_b => [
      'active' => FALSE,
      'class' => $this
        ->getMockClass(PaymentMethodInterface::class),
      'label' => $this
        ->randomMachineName(),
    ],
  ];
  $this->paymentMethodManager
    ->expects($this
    ->once())
    ->method('getDefinitions')
    ->willReturn($definitions);
  $build = $this->sut
    ->execute();
  $this
    ->assertIsArray($build);
}