mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-01 20:17:35 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			122 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			122 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * Invoice Ninja (https://invoiceninja.com).
 | |
|  *
 | |
|  * @link https://github.com/invoiceninja/invoiceninja source repository
 | |
|  *
 | |
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
 | |
|  *
 | |
|  * @license https://opensource.org/licenses/AAL
 | |
|  */
 | |
| namespace Tests\Feature;
 | |
| 
 | |
| use App\Factory\InvoiceItemFactory;
 | |
| use App\Utils\Traits\MakesHash;
 | |
| use Illuminate\Foundation\Testing\DatabaseTransactions;
 | |
| use Illuminate\Routing\Middleware\ThrottleRequests;
 | |
| use Tests\MockAccountData;
 | |
| use Tests\TestCase;
 | |
| 
 | |
| /**
 | |
|  * @test
 | |
|  */
 | |
| class DeleteInvoiceTest extends TestCase
 | |
| {
 | |
|     use DatabaseTransactions;
 | |
|     use MockAccountData;
 | |
|     use MakesHash;
 | |
|     
 | |
|     public function setUp() :void
 | |
|     {
 | |
|         parent::setUp();
 | |
| 
 | |
|         $this->makeTestData();
 | |
| 
 | |
|         $this->withoutMiddleware(
 | |
|             ThrottleRequests::class
 | |
|         );
 | |
|     }
 | |
| 
 | |
|     public function testInvoiceDeletion()
 | |
|     {
 | |
|         //create new client
 | |
|         
 | |
|         $data = [
 | |
|             'name' => 'A Nice Client',
 | |
|         ];
 | |
| 
 | |
|         $response = $this->withHeaders([
 | |
|                 'X-API-SECRET' => config('ninja.api_secret'),
 | |
|                 'X-API-TOKEN' => $this->token,
 | |
|             ])->post('/api/v1/clients', $data);
 | |
| 
 | |
|         $response->assertStatus(200);
 | |
| 
 | |
|         $arr = $response->json();
 | |
| 
 | |
|         $client_hash_id = $arr['data']['id'];
 | |
| 
 | |
|         //create new invoice.
 | |
| 
 | |
|         // $line_items = [];
 | |
| 
 | |
|         $item = InvoiceItemFactory::create();
 | |
|         $item->quantity = 1;
 | |
|         $item->cost = 10;
 | |
| 
 | |
|         $line_items[] = (array)$item;
 | |
| 
 | |
|         $item = InvoiceItemFactory::create();
 | |
|         $item->quantity = 1;
 | |
|         $item->cost = 10;
 | |
| 
 | |
|         $line_items[] = (array)$item;
 | |
| 
 | |
|         $invoice = [
 | |
|             'status_id' => 1,
 | |
|             'number' => 'dfdfd',
 | |
|             'discount' => 0,
 | |
|             'is_amount_discount' => 1,
 | |
|             'po_number' => '3434343',
 | |
|             'public_notes' => 'notes',
 | |
|             'is_deleted' => 0,
 | |
|             'custom_value1' => 0,
 | |
|             'custom_value2' => 0,
 | |
|             'custom_value3' => 0,
 | |
|             'custom_value4' => 0,
 | |
|             'client_id' => $client_hash_id,
 | |
|             'line_items' => (array)$line_items,
 | |
|         ];
 | |
| 
 | |
|         $response = $this->withHeaders([
 | |
|                 'X-API-SECRET' => config('ninja.api_secret'),
 | |
|                 'X-API-TOKEN' => $this->token,
 | |
|             ])->post('/api/v1/invoices/', $invoice)
 | |
|             ->assertStatus(200);
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|         
 | |
|         //mark as paid
 | |
|         
 | |
|         //test balance
 | |
|         
 | |
|         //hydrate associated payment
 | |
|         
 | |
|         //delete invoice
 | |
|         
 | |
|         //test ledger balance
 | |
|         
 | |
|         //test client balance
 | |
|         
 | |
|         //test client paid to date
 | |
| 
 | |
|         
 | |
|         
 | |
|     }
 | |
| }
 |