public function OrderIntegrationTest::testPaid in Commerce Invoice 8.2
Tests that the invoice total paid is updated when an order is paid.
File
- tests/
src/ Kernel/ OrderIntegrationTest.php, line 141
Class
- OrderIntegrationTest
- Tests integration with order events.
Namespace
Drupal\Tests\commerce_invoice\KernelCode
public function testPaid() {
$order_type = OrderType::load('default');
$order_type
->setThirdPartySetting('commerce_invoice', 'invoice_type', 'default');
$order_type
->setThirdPartySetting('commerce_invoice', 'order_placed_generation', TRUE);
$order_type
->save();
$this->order
->getState()
->applyTransitionById('place');
$this->order
->save();
$invoices = $this->invoiceStorage
->loadMultiple();
$this
->assertEquals(1, count($invoices));
/** @var \Drupal\commerce_invoice\Entity\InvoiceInterface $invoice */
$invoice = reset($invoices);
$this
->assertEquals(new Price('0.0', 'USD'), $invoice
->getTotalPaid());
$this->order
->setTotalPaid($this->order
->getTotalPrice());
$this->order
->save();
$this
->assertEquals($this->order
->getTotalPaid(), $invoice
->getTotalPaid());
}