2019-05-14 06:05:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Integration;
|
|
|
|
|
2019-05-16 08:00:27 +02:00
|
|
|
use App\Jobs\Invoice\MarkInvoicePaid;
|
2019-05-14 06:05:05 +02:00
|
|
|
use App\Models\Account;
|
|
|
|
use App\Models\Company;
|
|
|
|
use App\Models\Invoice;
|
|
|
|
use App\Models\Payment;
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\MockAccountData;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
2019-05-16 08:00:27 +02:00
|
|
|
* @covers App\Jobs\Invoice\MarkInvoicePaid
|
2019-05-14 06:05:05 +02:00
|
|
|
*/
|
2019-05-16 08:00:27 +02:00
|
|
|
class MarkInvoicePaidTest extends TestCase
|
2019-05-14 06:05:05 +02:00
|
|
|
{
|
|
|
|
use MockAccountData;
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function setUp() :void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->makeTestData();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testClientExists()
|
|
|
|
{
|
|
|
|
$this->assertNotNull($this->client);
|
|
|
|
}
|
|
|
|
|
2019-05-16 08:00:27 +02:00
|
|
|
public function testMarkInvoicePaidInvoice()
|
2019-05-14 06:05:05 +02:00
|
|
|
{
|
2019-05-16 08:00:27 +02:00
|
|
|
MarkInvoicePaid::dispatchNow($this->invoice);
|
2019-05-14 06:05:05 +02:00
|
|
|
|
|
|
|
$invoice = Invoice::find($this->invoice->id);
|
|
|
|
|
|
|
|
$this->assertEquals(0.00, $invoice->balance);
|
|
|
|
|
|
|
|
$this->assertEquals(1, count($invoice->payments));
|
|
|
|
|
|
|
|
foreach($invoice->payments as $payment) {
|
2019-05-14 12:27:47 +02:00
|
|
|
//Log::error($payment);
|
2019-09-04 14:01:19 +02:00
|
|
|
$this->assertEquals($this->invoice->amount, $payment->amount);
|
2019-05-14 06:05:05 +02:00
|
|
|
}
|
|
|
|
|
2019-10-02 22:01:12 +02:00
|
|
|
//events are not firing which makes this impossible to control.
|
|
|
|
// $this->assertEquals(Invoice::STATUS_PAID, $invoice->status_id);
|
2019-05-14 06:05:05 +02:00
|
|
|
|
|
|
|
$this->assertEquals(0.00, $invoice->balance);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|