2020-05-06 13:49:42 +02:00
|
|
|
<?php
|
2020-09-14 13:11:46 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-09-14 13:11:46 +02:00
|
|
|
*
|
2022-06-21 11:57:17 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-09-14 13:11:46 +02:00
|
|
|
*/
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2020-05-06 13:49:42 +02:00
|
|
|
namespace Tests\Unit;
|
|
|
|
|
2024-01-29 03:03:54 +01:00
|
|
|
use Tests\TestCase;
|
|
|
|
use App\Models\Invoice;
|
|
|
|
use Tests\MockAccountData;
|
2020-05-06 13:49:42 +02:00
|
|
|
use App\Helpers\Invoice\InvoiceSum;
|
2024-01-29 03:03:54 +01:00
|
|
|
use App\Models\Client;
|
|
|
|
use App\Models\Credit;
|
|
|
|
use App\Models\Document;
|
|
|
|
use App\Models\Expense;
|
|
|
|
use App\Models\Payment;
|
|
|
|
use App\Models\Product;
|
|
|
|
use App\Models\Project;
|
|
|
|
use App\Models\PurchaseOrder;
|
|
|
|
use App\Models\Quote;
|
|
|
|
use App\Models\Task;
|
|
|
|
use App\Models\Vendor;
|
2020-05-06 13:49:42 +02:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
|
|
|
|
/**
|
2024-09-16 13:13:55 +02:00
|
|
|
*
|
2020-05-06 13:49:42 +02:00
|
|
|
*/
|
|
|
|
class EntityTest extends TestCase
|
|
|
|
{
|
|
|
|
use MockAccountData;
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public $invoice;
|
|
|
|
|
|
|
|
public $invoice_calc;
|
|
|
|
|
|
|
|
public $settings;
|
|
|
|
|
2024-08-22 08:57:52 +02:00
|
|
|
protected function setUp(): void
|
2020-05-06 13:49:42 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-05-06 13:49:42 +02:00
|
|
|
$this->makeTestData();
|
|
|
|
|
|
|
|
$this->invoice->line_items = $this->buildLineItems();
|
|
|
|
|
|
|
|
$this->invoice_calc = new InvoiceSum($this->invoice);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testEntityNameResolution()
|
|
|
|
{
|
|
|
|
$entity_type = $this->invoice->getEntityType();
|
|
|
|
|
|
|
|
$this->assertEquals('Invoice', class_basename($entity_type));
|
|
|
|
|
|
|
|
$invitation = $this->invoice->invitations->first();
|
|
|
|
|
|
|
|
$entity_type = $invitation->getEntityType();
|
|
|
|
|
|
|
|
$this->assertEquals('InvoiceInvitation', class_basename($entity_type));
|
|
|
|
|
|
|
|
$this->assertEquals('InvoiceInvitation', class_basename($invitation));
|
|
|
|
}
|
2024-01-29 03:03:54 +01:00
|
|
|
|
|
|
|
public function testDocumentRelationExists()
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->assertTrue(method_exists(Invoice::class, 'documents'));
|
|
|
|
$this->assertTrue(method_exists(Quote::class, 'documents'));
|
|
|
|
$this->assertTrue(method_exists(Credit::class, 'documents'));
|
|
|
|
$this->assertTrue(method_exists(PurchaseOrder::class, 'documents'));
|
|
|
|
$this->assertTrue(method_exists(Client::class, 'documents'));
|
|
|
|
$this->assertTrue(method_exists(Vendor::class, 'documents'));
|
|
|
|
$this->assertTrue(method_exists(Product::class, 'documents'));
|
|
|
|
$this->assertTrue(method_exists(Payment::class, 'documents'));
|
|
|
|
$this->assertTrue(method_exists(Expense::class, 'documents'));
|
|
|
|
$this->assertTrue(method_exists(Project::class, 'documents'));
|
|
|
|
$this->assertTrue(method_exists(Task::class, 'documents'));
|
|
|
|
|
|
|
|
}
|
2024-08-22 08:57:52 +02:00
|
|
|
}
|