public function PaymentMethodTest::testPaymentMethodDeletion in Commerce Core 8.2
Tests deleting a payment method.
File
- modules/
payment/ tests/ src/ Functional/ PaymentMethodTest.php, line 256
Class
- PaymentMethodTest
- Tests the payment method UI.
Namespace
Drupal\Tests\commerce_payment\FunctionalCode
public function testPaymentMethodDeletion() {
$payment_method = $this
->createEntity('commerce_payment_method', [
'uid' => $this->user
->id(),
'type' => 'credit_card',
'payment_gateway' => 'example',
]);
$details = [
'type' => 'visa',
'number' => '4111111111111111',
'expiration' => [
'month' => '01',
'year' => date("Y") + 1,
],
];
$this->paymentGateway
->getPlugin()
->createPaymentMethod($payment_method, $details);
$this->paymentGateway
->save();
$this
->drupalGet($this->collectionUrl . '/' . $payment_method
->id() . '/delete');
$this
->getSession()
->getPage()
->pressButton('Delete');
$this
->assertSession()
->addressEquals($this->collectionUrl);
$payment_gateway = PaymentMethod::load($payment_method
->id());
$this
->assertNull($payment_gateway);
}