Fixes for tests - new implementation for invitations

This commit is contained in:
David Bomba 2019-06-02 16:36:31 +10:00
parent 96f61865d8
commit 4e4d134230
5 changed files with 10 additions and 22 deletions

View File

@ -1,4 +1,4 @@
<?php
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*

View File

@ -46,7 +46,7 @@
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"laravel/dusk": "^4.0",
"laravel/dusk": "^5.0",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"

View File

@ -226,7 +226,7 @@ class ClientTest extends TestCase
'user_id' => $user->id,
'client_id' => $c->id,
'company_id' => $company->id,
'is_primary' => 1
'is_primary' => 1,
]);
factory(\App\Models\ClientContact::class,2)->create([
@ -247,10 +247,8 @@ class ClientTest extends TestCase
/* Make sure we are harvesting valid data */
$this->assertEquals($client->timezone()->name, 'US/Eastern');
$contacts = ClientContact::whereIn('id', explode(',', $client->getMergedSettings()->invoice_email_list))->get();
/* Make sure NULL settings return the correct count (0) instead of throwing an exception*/
$this->assertEquals(count($contacts), 0);
$this->assertEquals($client->contacts->count(), 3);
}
}

View File

@ -5,6 +5,7 @@ namespace Feature;
use App\DataMapper\ClientSettings;
use App\DataMapper\DefaultSettings;
use App\Events\Invoice\InvoiceWasMarkedSent;
use App\Factory\InvoiceInvitationFactory;
use App\Jobs\Account\CreateAccount;
use App\Listeners\Invoice\CreateInvoiceInvitations;
use App\Models\Account;
@ -108,23 +109,13 @@ class InvitationTest extends TestCase
$this->assertNotNull($invoice->client);
$this->assertNotNull($invoice->client->primary_contact);
$arr[] = $invoice->client->primary_contact->first()->id;
$settings = $invoice->settings;
$settings->invoice_email_list = implode(",",$arr);
$i = InvoiceInvitationFactory::create($invoice->company_id, $invoice->user_id);
$i->client_contact_id = $client->primary_contact->first()->id;
$i->invoice_id = $invoice->id;
$i->save();
$invoice->settings = $settings;
$invoice->save();
$listener = new CreateInvoiceInvitations();
$listener->handle(new InvoiceWasMarkedSent($invoice));
$i = InvoiceInvitation::whereClientContactId($invoice->client->primary_contact->first()->id)->whereInvoiceId($invoice->id)->first();
$this->assertNotNull($i);
$this->assertNotNull($invoice->invitations);
$this->assertEquals($i->invoice_id, $invoice->id);
}
}

View File

@ -59,7 +59,6 @@ class CompareObjectTest extends TestCase
$this->assertEquals($settings->currency_id, 1);
$this->assertEquals($settings->language_id, 1);
$this->assertEquals($settings->payment_terms, 7);
$this->assertTrue(property_exists($settings, 'invoice_email_list'));
$this->assertEquals($settings->custom_taxes1, 'FALSE');
}