mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 15:47:32 -04:00 
			
		
		
		
	* Adjustments for tests * Implement handling of temp downloading resources * Refactor paths * Refactors for file paths * Refactor paths * Add in S3 adapter * Refactor company Documment URL * Refactor for entity pdf performance * Refactors for invoice generation * Enhancements for emails invoices * Emails * Fixes for client portal queries
		
			
				
	
	
		
			71 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			2.0 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\ActionsInvoice
 | |
|  */
 | |
| 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->invoice));
 | |
|         $this->assertTrue($this->invoiceReversable($this->invoice));
 | |
|         $this->assertTrue($this->invoiceCancellable($this->invoice));
 | |
|     }
 | |
| 
 | |
|     public function testInvoiceIsReversable()
 | |
|     {
 | |
|         $this->invoice->service()->markPaid()->save();
 | |
| 
 | |
|         $this->assertFalse($this->invoiceDeletable($this->invoice));
 | |
|         $this->assertTrue($this->invoiceReversable($this->invoice));
 | |
|         $this->assertFalse($this->invoiceCancellable($this->invoice));
 | |
|     }
 | |
| 
 | |
|     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->invoice));
 | |
|         $this->assertTrue($this->invoiceReversable($this->invoice));
 | |
|         $this->assertTrue($this->invoiceCancellable($this->invoice));
 | |
|     }
 | |
| 
 | |
|     public function testInvoiceUnactionable()
 | |
|     {
 | |
|         $this->invoice->delete();
 | |
| 
 | |
|         
 | |
|         $this->assertFalse($this->invoiceDeletable($this->invoice));
 | |
|         $this->assertFalse($this->invoiceReversable($this->invoice));
 | |
|         $this->assertFalse($this->invoiceCancellable($this->invoice));
 | |
|     }
 | |
| }
 |