public function DefaultPaymentAdminTest::testPaymentRefund in Commerce Core 8.2
Tests refunding a payment after capturing.
File
- modules/
payment/ tests/ src/ Functional/ DefaultPaymentAdminTest.php, line 215
Class
- DefaultPaymentAdminTest
- Tests the admin UI for payments of type 'payment_default'.
Namespace
Drupal\Tests\commerce_payment\FunctionalCode
public function testPaymentRefund() {
$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, TRUE);
$this
->drupalGet($this->paymentUri);
$this
->assertSession()
->elementContains('css', 'table tbody tr td:nth-child(2)', 'Completed');
$this
->drupalGet($this->paymentUri . '/' . $payment
->id() . '/operation/refund');
$this
->submitForm([
'payment[amount][number]' => '10',
], 'Refund');
$this
->assertSession()
->addressEquals($this->paymentUri);
$this
->assertSession()
->elementNotContains('css', 'table tbody tr td:nth-child(2)', 'Completed');
$this
->assertSession()
->pageTextContains('Refunded');
\Drupal::entityTypeManager()
->getStorage('commerce_payment')
->resetCache([
$payment
->id(),
]);
$payment = Payment::load($payment
->id());
$this
->assertEquals($payment
->getState()
->getLabel(), 'Refunded');
}