You are here

public function BasicTest::testSubmitConfigurationForm in Payment 8.2

Same name in this branch
  1. 8.2 tests/src/Unit/Plugin/Payment/MethodConfiguration/BasicTest.php \Drupal\Tests\payment\Unit\Plugin\Payment\MethodConfiguration\BasicTest::testSubmitConfigurationForm()
  2. 8.2 tests/src/Unit/Plugin/Payment/LineItem/BasicTest.php \Drupal\Tests\payment\Unit\Plugin\Payment\LineItem\BasicTest::testSubmitConfigurationForm()

@covers ::submitConfigurationForm @covers ::getExecutePaymentStatusSelector @covers ::getCapturePaymentStatusSelector @covers ::getRefundPaymentStatusSelector @covers ::getPaymentStatusSelector

File

tests/src/Unit/Plugin/Payment/MethodConfiguration/BasicTest.php, line 224

Class

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

Namespace

Drupal\Tests\payment\Unit\Plugin\Payment\MethodConfiguration

Code

public function testSubmitConfigurationForm() {
  $brand_label = $this
    ->randomMachineName();
  $message = $this
    ->randomMachineName();
  $execute_status_id = $this
    ->randomMachineName();
  $capture = TRUE;
  $capture_status_id = $this
    ->randomMachineName();
  $refund = TRUE;
  $refund_status_id = $this
    ->randomMachineName();
  $payment_status = $this
    ->createMock(PaymentStatusInterface::class);
  $this->paymentStatusManager
    ->expects($this
    ->atLeastOnce())
    ->method('createInstance')
    ->willReturn($payment_status);
  $payment_status_selector = $this
    ->createMock(PluginSelectorInterface::class);
  $payment_status_selector
    ->expects($this
    ->atLeastOnce())
    ->method('getSelectedPlugin')
    ->willReturn($payment_status);
  $this->pluginSelectorManager
    ->expects($this
    ->atLeastOnce())
    ->method('createInstance')
    ->willReturn($payment_status_selector);
  $form = array(
    'message' => array(
      '#parents' => array(
        'foo',
        'bar',
        'message',
      ),
    ),
    'plugin_form' => array(
      'brand_label' => array(
        '#parents' => array(
          'foo',
          'bar',
          'status',
        ),
      ),
      'execute' => [
        'execute_status' => [
          '#foo' => $this
            ->randomMachineName(),
        ],
      ],
      'capture' => [
        'plugin_form' => [
          'capture_status' => [
            '#foo' => $this
              ->randomMachineName(),
          ],
        ],
      ],
      'refund' => [
        'plugin_form' => [
          'refund_status' => [
            '#foo' => $this
              ->randomMachineName(),
          ],
        ],
      ],
    ),
  );
  $form_state = new FormState();
  $form_state
    ->setValues([
    'foo' => array(
      'bar' => array(
        'brand_label' => $brand_label,
        'message' => $message,
        'execute' => array(
          'execute_status_id' => $execute_status_id,
        ),
        'capture' => array(
          'capture' => $capture,
          'capture_status_id' => $capture_status_id,
        ),
        'refund' => array(
          'refund' => $refund,
          'refund_status_id' => $refund_status_id,
        ),
      ),
    ),
  ]);
  $this->sut
    ->submitConfigurationForm($form, $form_state);
  $this
    ->assertSame($brand_label, $this->sut
    ->getBrandLabel());
  $this
    ->assertSame($capture, $this->sut
    ->getCapture());
  $this
    ->assertSame($refund, $this->sut
    ->getRefund());
}