You are here

public function DefaultPaymentAdminTest::testPaymentDelete in Commerce Core 8.2

Tests deleting a payment after creation.

File

modules/payment/tests/src/Functional/DefaultPaymentAdminTest.php, line 269

Class

DefaultPaymentAdminTest
Tests the admin UI for payments of type 'payment_default'.

Namespace

Drupal\Tests\commerce_payment\Functional

Code

public function testPaymentDelete() {
  $payment = $this
    ->createEntity('commerce_payment', [
    'payment_gateway' => $this->paymentGateway
      ->id(),
    'payment_method' => $this->paymentMethod
      ->id(),
    'order_id' => $this->order
      ->id(),
    'amount' => new Price('10', 'USD'),
  ]);
  $this->paymentGateway
    ->getPlugin()
    ->createPayment($payment, FALSE);
  $this
    ->drupalGet($this->paymentUri);
  $this
    ->assertSession()
    ->pageTextContains('Authorization');
  $this
    ->drupalGet($this->paymentUri . '/' . $payment
    ->id() . '/delete');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Delete');
  $this
    ->assertSession()
    ->addressEquals($this->paymentUri);
  $this
    ->assertSession()
    ->pageTextNotContains('Authorization');
  \Drupal::entityTypeManager()
    ->getStorage('commerce_payment')
    ->resetCache([
    $payment
      ->id(),
  ]);
  $payment = Payment::load($payment
    ->id());
  $this
    ->assertNull($payment);
}