mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Finalize tests for Factories
This commit is contained in:
parent
a9fe211799
commit
acdc8fad94
@ -10,7 +10,7 @@ class CloneInvoiceFactory
|
||||
{
|
||||
$clone_invoice = $invoice->replicate();
|
||||
$clone_invoice->status_id = Invoice::STATUS_DRAFT;
|
||||
$clone_invoice->invoice_number = '';
|
||||
$clone_invoice->invoice_number = NULL;
|
||||
$clone_invoice->invoice_date = null;
|
||||
$clone_invoice->due_date = null;
|
||||
$clone_invoice->partial_due_date = null;
|
||||
|
@ -9,9 +9,9 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class InvoiceFactory
|
||||
{
|
||||
public static function create(int $company_id, int $user_id) :\stdClass
|
||||
public static function create(int $company_id, int $user_id) :Invoice
|
||||
{
|
||||
$invoice = new \stdClass;
|
||||
$invoice = new Invoice();
|
||||
$invoice->status_id = Invoice::STATUS_DRAFT;
|
||||
$invoice->invoice_number = '';
|
||||
$invoice->discount = 0;
|
||||
|
@ -343,7 +343,7 @@ class CreateUsersTable extends Migration
|
||||
$t->unsignedInteger('company_id')->index();
|
||||
$t->unsignedInteger('status_id');
|
||||
|
||||
$t->string('invoice_number');
|
||||
$t->string('invoice_number')->nullable();
|
||||
$t->float('discount');
|
||||
$t->boolean('is_amount_discount');
|
||||
|
||||
|
@ -4,6 +4,9 @@ namespace Tests\Unit;
|
||||
|
||||
use App\Factory\ClientContactFactory;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Factory\CloneInvoiceFactory;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Factory\ProductFactory;
|
||||
use App\Factory\UserFactory;
|
||||
use App\Models\Client;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -46,6 +49,69 @@ class FactoryCreationTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers App\Factory\ProductFactory
|
||||
*/
|
||||
public function testProductionCreation()
|
||||
{
|
||||
$product = ProductFactory::create($this->company->id, $this->user->id);
|
||||
$product->save();
|
||||
|
||||
$this->assertNotNull($product);
|
||||
|
||||
$this->assertInternalType("int", $product->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers App\Factory\InvoiceFactory
|
||||
*/
|
||||
|
||||
public function testInvoiceCreation()
|
||||
{
|
||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||
|
||||
$client->save();
|
||||
|
||||
$invoice = InvoiceFactory::create($this->company->id,$this->user->id);//stub the company and user_id
|
||||
$invoice->client_id = $client->id;
|
||||
$invoice->save();
|
||||
|
||||
$this->assertNotNull($invoice);
|
||||
|
||||
$this->assertInternalType("int", $invoice->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers App|Factory\CloneInvoiceFactory
|
||||
*/
|
||||
public function testCloneInvoiceCreation()
|
||||
{
|
||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||
|
||||
$client->save();
|
||||
|
||||
$invoice = InvoiceFactory::create($this->company->id,$this->user->id);//stub the company and user_id
|
||||
$invoice->client_id = $client->id;
|
||||
$invoice->save();
|
||||
|
||||
$this->assertNotNull($invoice);
|
||||
|
||||
$this->assertInternalType("int", $invoice->id);
|
||||
|
||||
|
||||
$clone = CloneInvoiceFactory::create($invoice, $this->user->id);
|
||||
$clone->save();
|
||||
|
||||
$this->assertNotNull($clone);
|
||||
|
||||
$this->assertInternalType("int", $clone->id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers App|Factory\ClientFactory
|
||||
|
Loading…
x
Reference in New Issue
Block a user