mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 09:34:33 -04:00
Tests for container manipulation
This commit is contained in:
parent
6840e3e471
commit
2e663447b8
@ -36,7 +36,7 @@ class EmailCredit extends BaseMailerJob implements ShouldQueue
|
|||||||
|
|
||||||
public $message_array = [];
|
public $message_array = [];
|
||||||
|
|
||||||
|
public $settings;
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
@ -45,6 +45,8 @@ class EmailCredit extends BaseMailerJob implements ShouldQueue
|
|||||||
public function __construct(Credit $credit)
|
public function __construct(Credit $credit)
|
||||||
{
|
{
|
||||||
$this->credit = $credit;
|
$this->credit = $credit;
|
||||||
|
|
||||||
|
$this->settings = $credit->client->getMergedSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +61,7 @@ class EmailCredit extends BaseMailerJob implements ShouldQueue
|
|||||||
|
|
||||||
$template_style = $this->credit->client->getSetting('email_style');
|
$template_style = $this->credit->client->getSetting('email_style');
|
||||||
|
|
||||||
$this->setMailDriver($this->credit->client->getSetting('email_sending_method'));
|
$this->setMailDriver();
|
||||||
|
|
||||||
$this->credit->invitations->each(function ($invitation) use ($template_style) {
|
$this->credit->invitations->each(function ($invitation) use ($template_style) {
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ class EmailInvoice extends BaseMailerJob implements ShouldQueue
|
|||||||
public $email_builder;
|
public $email_builder;
|
||||||
|
|
||||||
public $company;
|
public $company;
|
||||||
|
|
||||||
|
public $settings;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* EmailInvoice constructor.
|
* EmailInvoice constructor.
|
||||||
@ -55,6 +57,9 @@ class EmailInvoice extends BaseMailerJob implements ShouldQueue
|
|||||||
$this->invoice_invitation = $invoice_invitation;
|
$this->invoice_invitation = $invoice_invitation;
|
||||||
|
|
||||||
$this->email_builder = $email_builder;
|
$this->email_builder = $email_builder;
|
||||||
|
|
||||||
|
$this->settings = $invoice_invitation->contact->client->getMergedSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,7 +73,7 @@ class EmailInvoice extends BaseMailerJob implements ShouldQueue
|
|||||||
{
|
{
|
||||||
MultiDB::setDB($this->company->db);
|
MultiDB::setDB($this->company->db);
|
||||||
|
|
||||||
$this->setMailDriver($this->invoice_invitation->invoice->client->getSetting('email_sending_method'));
|
$this->setMailDriver();
|
||||||
|
|
||||||
Mail::to($this->invoice_invitation->contact->email, $this->invoice_invitation->contact->present()->name())
|
Mail::to($this->invoice_invitation->contact->email, $this->invoice_invitation->contact->present()->name())
|
||||||
->send(
|
->send(
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Jobs\Invoice;
|
namespace App\Jobs\Invoice;
|
||||||
|
|
||||||
|
use App\Jobs\Mail\BaseMailerJob;
|
||||||
use App\Jobs\Util\UnlinkFile;
|
use App\Jobs\Util\UnlinkFile;
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
use App\Mail\DownloadInvoices;
|
use App\Mail\DownloadInvoices;
|
||||||
@ -27,7 +28,7 @@ use Illuminate\Support\Facades\Storage;
|
|||||||
use ZipStream\Option\Archive;
|
use ZipStream\Option\Archive;
|
||||||
use ZipStream\ZipStream;
|
use ZipStream\ZipStream;
|
||||||
|
|
||||||
class ZipInvoices implements ShouldQueue
|
class ZipInvoices extends BaseMailerJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ class ZipInvoices implements ShouldQueue
|
|||||||
|
|
||||||
private $email;
|
private $email;
|
||||||
|
|
||||||
|
public $settings;
|
||||||
/**
|
/**
|
||||||
* @deprecated confirm to be deleted
|
* @deprecated confirm to be deleted
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
@ -50,6 +52,8 @@ class ZipInvoices implements ShouldQueue
|
|||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
|
|
||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
|
|
||||||
|
$this->settings = $company->settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,6 +86,8 @@ class ZipInvoices implements ShouldQueue
|
|||||||
|
|
||||||
fclose($tempStream);
|
fclose($tempStream);
|
||||||
|
|
||||||
|
$this->setMailDriver();
|
||||||
|
|
||||||
Mail::to($this->email)
|
Mail::to($this->email)
|
||||||
->send(new DownloadInvoices(Storage::disk(config('filesystems.default'))->url($path . $file_name), $this->company));
|
->send(new DownloadInvoices(Storage::disk(config('filesystems.default'))->url($path . $file_name), $this->company));
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ class BaseMailerJob implements ShouldQueue
|
|||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
public function setMailDriver(string $driver)
|
public function setMailDriver()
|
||||||
{
|
{
|
||||||
switch ($driver) {
|
switch ($this->settings->email_sending_method) {
|
||||||
case 'default':
|
case 'default':
|
||||||
break;
|
break;
|
||||||
case 'gmail':
|
case 'gmail':
|
||||||
@ -45,7 +45,7 @@ class BaseMailerJob implements ShouldQueue
|
|||||||
|
|
||||||
public function setGmailMailer()
|
public function setGmailMailer()
|
||||||
{
|
{
|
||||||
$sending_user = $this->entity->client->getSetting('gmail_sending_user_id');
|
$sending_user = $this->settings->gmail_sending_user_id;
|
||||||
|
|
||||||
$user = User::find($sending_user);
|
$user = User::find($sending_user);
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
public $entity_type;
|
public $entity_type;
|
||||||
|
|
||||||
public $entity;
|
public $entity;
|
||||||
|
|
||||||
|
public $settings;
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
@ -55,6 +57,9 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
|
||||||
$this->payment = $payment;
|
$this->payment = $payment;
|
||||||
|
|
||||||
|
$this->settings = $payment->client->getMergedSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +77,7 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
//if we need to set an email driver do it now
|
//if we need to set an email driver do it now
|
||||||
$this->setMailDriver($this->payment->client->getSetting('email_sending_method'));
|
$this->setMailDriver();
|
||||||
|
|
||||||
$mail_obj = (new EntityPaidObject($this->payment))->build();
|
$mail_obj = (new EntityPaidObject($this->payment))->build();
|
||||||
$mail_obj->from = [$this->payment->user->email, $this->payment->user->present()->name()];
|
$mail_obj->from = [$this->payment->user->email, $this->payment->user->present()->name()];
|
||||||
|
@ -42,6 +42,9 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
public $entity_type;
|
public $entity_type;
|
||||||
|
|
||||||
public $entity;
|
public $entity;
|
||||||
|
|
||||||
|
public $settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
@ -58,6 +61,8 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
$this->entity = $invitation->{$entity_type};
|
$this->entity = $invitation->{$entity_type};
|
||||||
|
|
||||||
$this->entity_type = $entity_type;
|
$this->entity_type = $entity_type;
|
||||||
|
|
||||||
|
$this->settings = $invitation->contact->client->getMergedSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,7 +76,7 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
//if we need to set an email driver do it now
|
//if we need to set an email driver do it now
|
||||||
$this->setMailDriver($this->entity->client->getSetting('email_sending_method'));
|
$this->setMailDriver();
|
||||||
|
|
||||||
$mail_obj = (new EntitySentObject($this->invitation, $this->entity_type))->build();
|
$mail_obj = (new EntitySentObject($this->invitation, $this->entity_type))->build();
|
||||||
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
|
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
|
||||||
|
@ -42,6 +42,8 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
public $entity_type;
|
public $entity_type;
|
||||||
|
|
||||||
public $entity;
|
public $entity;
|
||||||
|
|
||||||
|
public $settings;
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
@ -58,6 +60,9 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
$this->entity = $invitation->{$entity_type};
|
$this->entity = $invitation->{$entity_type};
|
||||||
|
|
||||||
$this->entity_type = $entity_type;
|
$this->entity_type = $entity_type;
|
||||||
|
|
||||||
|
$this->settings = $invitation->contact->client->getMergedSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +77,7 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
//if we need to set an email driver do it now
|
//if we need to set an email driver do it now
|
||||||
$this->setMailDriver($this->entity->client->getSetting('email_sending_method'));
|
$this->setMailDriver();
|
||||||
|
|
||||||
$mail_obj = (new EntityViewedObject($this->invitation, $this->entity_type))->build();
|
$mail_obj = (new EntityViewedObject($this->invitation, $this->entity_type))->build();
|
||||||
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
|
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
|
||||||
|
@ -17,6 +17,7 @@ use App\Libraries\Google\Google;
|
|||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
use App\Mail\Admin\EntityNotificationMailer;
|
use App\Mail\Admin\EntityNotificationMailer;
|
||||||
use App\Mail\Admin\EntitySentObject;
|
use App\Mail\Admin\EntitySentObject;
|
||||||
|
use App\Models\ClientContact;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@ -45,6 +46,8 @@ class MailRouter extends BaseMailerJob implements ShouldQueue
|
|||||||
|
|
||||||
public $sending_method;
|
public $sending_method;
|
||||||
|
|
||||||
|
public $settings;
|
||||||
|
|
||||||
public function __construct(Mailable $mailable, Company $company, $to_user, string $sending_method)
|
public function __construct(Mailable $mailable, Company $company, $to_user, string $sending_method)
|
||||||
{
|
{
|
||||||
$this->mailable = $mailable;
|
$this->mailable = $mailable;
|
||||||
@ -54,6 +57,11 @@ class MailRouter extends BaseMailerJob implements ShouldQueue
|
|||||||
$this->to_user = $to_user;
|
$this->to_user = $to_user;
|
||||||
|
|
||||||
$this->sending_method = $sending_method;
|
$this->sending_method = $sending_method;
|
||||||
|
|
||||||
|
if($to_user instanceof ClientContact)
|
||||||
|
$this->settings = $to_user->client->getMergedSettings();
|
||||||
|
else
|
||||||
|
$this->settings = $this->company->settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
@ -61,7 +69,7 @@ class MailRouter extends BaseMailerJob implements ShouldQueue
|
|||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
//if we need to set an email driver do it now
|
//if we need to set an email driver do it now
|
||||||
$this->setMailDriver($sending_method);
|
$this->setMailDriver();
|
||||||
|
|
||||||
//send email
|
//send email
|
||||||
Mail::to($this->to_user->email)
|
Mail::to($this->to_user->email)
|
||||||
|
@ -44,6 +44,8 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
|
|
||||||
public $amount;
|
public $amount;
|
||||||
|
|
||||||
|
public $settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
@ -58,6 +60,8 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
|
|
||||||
$this->amount = $amount;
|
$this->amount = $amount;
|
||||||
|
|
||||||
|
$this->settings = $client->getMergedSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +76,7 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
|
|||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
//if we need to set an email driver do it now
|
//if we need to set an email driver do it now
|
||||||
$this->setMailDriver($this->client->getSetting('email_sending_method'));
|
$this->setMailDriver();
|
||||||
|
|
||||||
//iterate through company_users
|
//iterate through company_users
|
||||||
$this->company->company_users->each(function ($company_user){
|
$this->company->company_users->each(function ($company_user){
|
||||||
|
@ -34,6 +34,7 @@ class UserEmailChanged extends BaseMailerJob implements ShouldQueue
|
|||||||
|
|
||||||
protected $company;
|
protected $company;
|
||||||
|
|
||||||
|
public $settings;
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
@ -45,6 +46,8 @@ class UserEmailChanged extends BaseMailerJob implements ShouldQueue
|
|||||||
$this->new_email = $new_email;
|
$this->new_email = $new_email;
|
||||||
$this->old_email = $old_email;
|
$this->old_email = $old_email;
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
|
$this->settings = $this->company->settings;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
@ -53,7 +56,7 @@ class UserEmailChanged extends BaseMailerJob implements ShouldQueue
|
|||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
//If we need to set an email driver do it now
|
//If we need to set an email driver do it now
|
||||||
$this->setMailDriver($this->company->settings->email_sending_method);
|
$this->setMailDriver();
|
||||||
|
|
||||||
/*Build the object*/
|
/*Build the object*/
|
||||||
$mail_obj = new \stdClass;
|
$mail_obj = new \stdClass;
|
||||||
|
45
tests/Integration/ContainerTest.php
Normal file
45
tests/Integration/ContainerTest.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Integration;
|
||||||
|
|
||||||
|
use App\Models\Company;
|
||||||
|
use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Tests\MockAccountData;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
class ContainerTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
use MockAccountData;
|
||||||
|
|
||||||
|
public function setUp() :void
|
||||||
|
{
|
||||||
|
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->makeTestData();
|
||||||
|
|
||||||
|
app()->instance(Company::class, $this->company);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testBindingWorks()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$resolved_company = resolve(Company::class);
|
||||||
|
|
||||||
|
$this->assertNotNull($resolved_company);
|
||||||
|
|
||||||
|
$this->assertEquals($this->account->id, $resolved_company->account_id);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user