public function ManualPaymentAdminTest::testPaymentReceive in Commerce Core 8.2
Tests receiving a payment after creation.
File
- modules/
payment/ tests/ src/ Functional/ ManualPaymentAdminTest.php, line 140
Class
- ManualPaymentAdminTest
- Tests the admin UI for payments of type 'payment_manual'.
Namespace
Drupal\Tests\commerce_payment\FunctionalCode
public function testPaymentReceive() {
$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);
$this
->drupalGet($this->paymentUri . '/' . $payment
->id() . '/operation/receive');
$this
->submitForm([
'payment[amount][number]' => '10',
], 'Receive');
$this
->assertSession()
->addressEquals($this->paymentUri);
$this
->assertSession()
->pageTextNotContains('Pending');
$this
->assertSession()
->elementContains('css', 'table tbody tr td:nth-child(2)', 'Completed');
\Drupal::entityTypeManager()
->getStorage('commerce_payment')
->resetCache([
$payment
->id(),
]);
$payment = Payment::load($payment
->id());
$this
->assertEquals($payment
->getState()
->getLabel(), 'Completed');
}