You are here

public function ManagePaymentMethodsTest::testAddingPaymentMethod in Commerce Authorize.Net 8

Tests than an order can go through checkout steps.

@group registered

File

tests/src/Functional/ManagePaymentMethodsTest.php, line 76

Class

ManagePaymentMethodsTest
Tests the managing Authorize.net payment methods.

Namespace

Drupal\Tests\commerce_authnet\Functional

Code

public function testAddingPaymentMethod() {
  $this
    ->drupalGet(Url::fromRoute('entity.commerce_payment_method.add_form', [
    'user' => $this->loggedInUser
      ->id(),
  ])
    ->toString());
  $this
    ->assertSession()
    ->pageTextContains('Add payment method');
  $this
    ->submitForm([
    'payment_method[payment_details][number]' => '4111111111111111',
    'payment_method[payment_details][expiration][month]' => '2',
    'payment_method[payment_details][expiration][year]' => '2027',
    'payment_method[payment_details][security_code]' => '123',
    'payment_method[billing_information][address][0][address][given_name]' => 'Johnny',
    'payment_method[billing_information][address][0][address][family_name]' => 'Appleseed',
    'payment_method[billing_information][address][0][address][address_line1]' => '123 New York Drive',
    'payment_method[billing_information][address][0][address][locality]' => 'New York City',
    'payment_method[billing_information][address][0][address][administrative_area]' => 'NY',
    'payment_method[billing_information][address][0][address][postal_code]' => '10001',
  ], 'Save');
  $this
    ->assertSession()
    ->pageTextNotContains('We encountered an error processing your payment method. Please verify your details and try again.');
  $this
    ->assertSession()
    ->pageTextNotContains('We encountered an unexpected error processing your payment method. Please try again later.');
  $html_output = 'GET request to: ' . $this
    ->getSession()
    ->getCurrentUrl() . '<hr />Ending URL: ' . $this
    ->getSession()
    ->getCurrentUrl();
  $html_output .= '<hr />' . $this
    ->getSession()
    ->getPage()
    ->getContent();
  $html_output .= $this
    ->getHtmlOutputHeaders();
  $this
    ->htmlOutput($html_output);
}