1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/tests/Unit/InvoiceActionsTest.php
David Bomba 8cffccb3bc
Fixes for composer 2 (#3593)
* Add privacy link to setup page

* Italics

* Tests for invoice actions

* Fixes for autoloading
2020-04-06 22:32:27 +10:00

72 lines
1.8 KiB
PHP

<?php
namespace Tests\Unit;
use App\Factory\PaymentFactory;
use App\Utils\Traits\Invoice\ActionsInvoice;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\MockAccountData;
use Tests\TestCase;
/**
* @test
* @covers App\Utils\Traits\Invoice\ActionInvoice
*/
class InvoiceActionsTest extends TestCase
{
use MockAccountData;
use DatabaseTransactions;
use ActionsInvoice;
public function setUp() :void
{
parent::setUp();
$this->makeTestData();
}
public function testInvoiceIsDeletable()
{
$this->assertTrue($this->invoiceDeletable());
$this->assertFalse($this->invoiceReversable());
$this->assertFalse($this->invoiceCancellable());
}
public function testInvoiceIsReversable()
{
$this->invoice->service()->markPaid()->save();
$this->assertFalse($this->invoiceDeletable());
$this->assertTrue($this->invoiceReversable());
$this->assertFalse($this->invoiceCancellable());
}
public function testInvoiceIsCancellable()
{
$payment = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id);
$payment->amount = 40;
$payment->client_id = $this->invoice->client_id;
$payment->applied = 0;
$payment->refunded = 0;
$payment->date = now();
$payment->save();
$this->invoice->service()->applyPayment($payment, 5)->save();
$this->assertFalse($this->invoiceDeletable());
$this->assertTrue($this->invoiceReversable());
$this->assertTrue($this->invoiceCancellable());
}
public function testInvoiceUnactionable()
{
$this->invoice->delete();
$this->assertFalse($this->invoiceDeletable());
$this->assertFalse($this->invoiceReversable());
$this->assertFalse($this->invoiceCancellable());
}
}