public function ManualPaymentAdminTest::testPaymentRefund in Commerce Core 8.2
Tests refunding a completed payment.
File
- modules/
payment/ tests/ src/ Functional/ ManualPaymentAdminTest.php, line 162
Class
- ManualPaymentAdminTest
- Tests the admin UI for payments of type 'payment_manual'.
Namespace
Drupal\Tests\commerce_payment\FunctionalCode
public function testPaymentRefund() {
$payment = $this
->createEntity('commerce_payment', [
'payment_gateway' => $this->paymentGateway
->id(),
'order_id' => $this->order
->id(),
'amount' => new Price('10', 'USD'),
]);
$this->paymentGateway
->getPlugin()
->createPayment($payment, TRUE);
$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('Refunded', $payment
->getState()
->getLabel());
}