public function DefaultPaymentAdminTest::testPaymentVoid in Commerce Core 8.2
Tests voiding a payment after creation.
File
- modules/
payment/ tests/ src/ Functional/ DefaultPaymentAdminTest.php, line 242
Class
- DefaultPaymentAdminTest
- Tests the admin UI for payments of type 'payment_default'.
Namespace
Drupal\Tests\commerce_payment\FunctionalCode
public function testPaymentVoid() {
$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() . '/operation/void');
$this
->assertSession()
->pageTextContains('Are you sure you want to void the 10 USD payment?');
$this
->getSession()
->getPage()
->pressButton('Void');
$this
->assertSession()
->addressEquals($this->paymentUri);
$this
->assertSession()
->pageTextContains('Authorization (Voided)');
\Drupal::entityTypeManager()
->getStorage('commerce_payment')
->resetCache([
$payment
->id(),
]);
$payment = Payment::load($payment
->id());
$this
->assertEquals($payment
->getState()
->getLabel(), 'Authorization (Voided)');
}