public function InvoiceSubscriberTest::testPostTransition in Commerce Invoice 8.2
Tests that paying an invoice mark the orders as paid.
File
- tests/
src/ Kernel/ InvoiceSubscriberTest.php, line 98
Class
- InvoiceSubscriberTest
- Tests the InvoiceSubscriber.
Namespace
Drupal\Tests\commerce_invoice\KernelCode
public function testPostTransition() {
$this
->assertEquals(new Price('12.00', 'USD'), $this->order
->getTotalPrice());
$invoice_item = InvoiceItem::create([
'type' => 'test',
]);
$invoice_item
->populateFromOrderItem($this->orderItem);
$invoice_item
->save();
$invoice = Invoice::create([
'type' => 'default',
'store_id' => $this->store
->id(),
'invoice_items' => [
$invoice_item,
],
'orders' => [
$this->order,
],
]);
$invoice
->save();
$this
->assertEquals(new Price('12.00', 'USD'), $invoice
->getTotalPrice());
$this
->assertEquals(new Price('0', 'USD'), $invoice
->getTotalPaid());
$invoice
->setTotalPaid(new Price('10.00', 'USD'));
$invoice
->save();
$this
->assertFalse($invoice
->isPaid());
$this
->assertEquals(new Price('0', 'USD'), $this->order
->getTotalPaid());
$invoice
->setTotalPaid(new Price('12.00', 'USD'));
$invoice
->save();
$this
->assertTrue($invoice
->isPaid());
$this->order = $this
->reloadEntity($this->order);
$this
->assertEquals(new Price('12.00', 'USD'), $this->order
->getTotalPaid());
}