2020-04-30 13:45:47 +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-04-30 13:45:47 +02:00
|
|
|
namespace Tests\Integration;
|
|
|
|
|
|
|
|
use App\Jobs\Util\SendFailedEmails;
|
|
|
|
use App\Models\SystemLog;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\MockAccountData;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @covers App\Jobs\Util\SendFailedEmails
|
|
|
|
*/
|
|
|
|
class SendFailedEmailsTest extends TestCase
|
|
|
|
{
|
|
|
|
use MockAccountData;
|
2020-09-06 11:38:10 +02:00
|
|
|
use DatabaseTransactions;
|
2020-04-30 13:45:47 +02:00
|
|
|
|
2024-08-22 08:57:52 +02:00
|
|
|
protected function setUp(): void
|
2020-04-30 13:45:47 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->makeTestData();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testReminderFires()
|
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
$invitation = $this->invoice->invitations->first();
|
2020-10-28 00:02:32 +01:00
|
|
|
$reminder_template = $this->invoice->calculateTemplate('invoice');
|
2020-04-30 13:45:47 +02:00
|
|
|
|
|
|
|
$sl = [
|
2020-09-06 11:38:10 +02:00
|
|
|
'entity_name' => \App\Models\InvoiceInvitation::class,
|
2020-04-30 13:45:47 +02:00
|
|
|
'invitation_key' => $invitation->key,
|
|
|
|
'reminder_template' => $reminder_template,
|
|
|
|
'subject' => '',
|
|
|
|
'body' => '',
|
|
|
|
];
|
|
|
|
|
2024-08-22 08:57:52 +02:00
|
|
|
$system_log = new SystemLog();
|
2020-04-30 13:45:47 +02:00
|
|
|
$system_log->company_id = $this->invoice->company_id;
|
|
|
|
$system_log->client_id = $this->invoice->client_id;
|
|
|
|
$system_log->category_id = SystemLog::CATEGORY_MAIL;
|
|
|
|
$system_log->event_id = SystemLog::EVENT_MAIL_RETRY_QUEUE;
|
|
|
|
$system_log->type_id = SystemLog::TYPE_QUOTA_EXCEEDED;
|
|
|
|
$system_log->log = $sl;
|
|
|
|
$system_log->save();
|
|
|
|
|
|
|
|
$sys_log = SystemLog::where('event_id', SystemLog::EVENT_MAIL_RETRY_QUEUE)->first();
|
|
|
|
|
|
|
|
$this->assertNotNull($sys_log);
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
SendFailedEmails::dispatch();
|
2020-04-30 13:45:47 +02:00
|
|
|
}
|
|
|
|
}
|