1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 23:52:33 +01:00
invoiceninja/tests/Feature/InvoiceEmailTest.php

151 lines
4.5 KiB
PHP
Raw Normal View History

<?php
2020-09-14 13:11:46 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2020-09-14 13:11:46 +02:00
*
* @license https://opensource.org/licenses/AAL
*/
2020-10-28 11:10:49 +01:00
namespace Tests\Feature;
2020-10-28 07:27:10 +01:00
use App\Jobs\Entity\EmailEntity;
use App\Utils\Traits\GeneratesCounter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
use Tests\TestCase;
/**
* @test
* @covers App\Jobs\Invoice\EmailInvoice
*/
class InvoiceEmailTest extends TestCase
{
use MockAccountData;
use DatabaseTransactions;
use GeneratesCounter;
public function setUp() :void
{
parent::setUp();
Session::start();
$this->faker = \Faker\Factory::create();
Model::reguard();
$this->makeTestData();
}
public function test_initial_email_send_emails()
{
$this->invoice->date = now();
$this->invoice->due_date = now()->addDays(7);
2020-10-07 01:16:57 +02:00
$this->invoice->number = $this->getNextInvoiceNumber($this->client, $this->invoice);
2020-02-15 12:49:31 +01:00
$this->invoice->client_id = $this->client->id;
$client_settings = $this->client->settings;
$client_settings->email_style = 'dark';
$this->client->settings = $client_settings;
$this->client->save();
2020-02-15 12:49:31 +01:00
$this->invoice->setRelation('client', $this->client);
$this->invoice->save();
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
2020-10-28 07:27:10 +01:00
EmailEntity::dispatchNow($invitation, $invitation->company);
2020-10-28 07:27:10 +01:00
$this->expectsJobs(EmailEntity::class);
2020-02-15 12:49:31 +01:00
}
});
$this->assertTrue(true);
}
public function testTemplateThemes()
{
$settings = $this->company->settings;
$settings->email_style = 'light';
$this->company->settings = $settings;
$this->company->save();
$this->invoice->date = now();
$this->invoice->due_date = now()->addDays(7);
2020-10-07 01:16:57 +02:00
$this->invoice->number = $this->getNextInvoiceNumber($this->client, $this->invoice);
$this->invoice->client_id = $this->client->id;
$this->invoice->setRelation('client', $this->client);
$this->invoice->save();
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
2020-10-28 07:27:10 +01:00
EmailEntity::dispatchNow($invitation, $invitation->company);
2020-10-28 07:27:10 +01:00
$this->expectsJobs(EmailEntity::class);
}
});
$settings = $this->company->settings;
$settings->email_style = 'dark';
$this->company->settings = $settings;
$this->company->save();
$this->invoice->date = now();
$this->invoice->due_date = now()->addDays(7);
2020-10-07 01:16:57 +02:00
$this->invoice->number = $this->getNextInvoiceNumber($this->client, $this->invoice);
$this->invoice->client_id = $this->client->id;
$client_settings = $this->client->settings;
$client_settings->email_style = 'dark';
$this->client->settings = $client_settings;
$this->client->save();
$this->invoice->setRelation('client', $this->client);
$this->invoice->save();
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
2020-10-28 07:27:10 +01:00
EmailEntity::dispatchNow($invitation, $invitation->company);
2020-10-28 07:27:10 +01:00
$this->expectsJobs(EmailEntity::class);
}
});
$settings = $this->company->settings;
$settings->email_style = 'plain';
$this->company->settings = $settings;
$this->company->save();
$this->invoice->date = now();
$this->invoice->due_date = now()->addDays(7);
2020-10-07 01:16:57 +02:00
$this->invoice->number = $this->getNextInvoiceNumber($this->client, $this->invoice);
$this->invoice->client_id = $this->client->id;
$this->invoice->setRelation('client', $this->client);
$this->invoice->save();
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
2020-10-28 07:27:10 +01:00
EmailEntity::dispatchNow($invitation, $invitation->company);
2020-10-28 07:27:10 +01:00
$this->expectsJobs(EmailEntity::class);
}
});
$this->assertTrue(true);
}
2020-02-15 12:49:31 +01:00
}