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

File

tests/src/Unit/Plugin/Payment/LineItem/BasicTest.php, line 133

Class

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

Namespace

Drupal\Tests\payment\Unit\Plugin\Payment\LineItem

Code

public function testSubmitConfigurationForm() {
  $amount = mt_rand();
  $currency_code = $this
    ->randomMachineName(3);
  $description = $this
    ->randomMachineName();
  $name = $this
    ->randomMachineName();
  $payment_id = mt_rand();
  $quantity = mt_rand();
  $form = array(
    '#parents' => array(
      'foo',
      'bar',
    ),
  );
  $form_state = $this
    ->createMock(FormStateInterface::class);
  $form_state
    ->expects($this
    ->atLeastOnce())
    ->method('getValues')
    ->willReturn(array(
    'foo' => array(
      'bar' => array(
        'amount' => array(
          'amount' => $amount,
          'currency_code' => $currency_code,
        ),
        'description' => $description,
        'name' => $name,
        'payment_id' => $payment_id,
        'quantity' => $quantity,
      ),
    ),
  ));
  $this->sut
    ->submitConfigurationForm($form, $form_state);
  $this
    ->assertSame($amount, $this->sut
    ->getAmount());
  $this
    ->assertSame($currency_code, $this->sut
    ->getCurrencyCode());
  $this
    ->assertSame($description, $this->sut
    ->getDescription());
  $this
    ->assertSame($name, $this->sut
    ->getName());
  $this
    ->assertSame($quantity, $this->sut
    ->getQuantity());
}