-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: restrict to laravel 9 * fix: upgrade * fix: wip * fix: wip * fix: wip * fix: wip * fix: phpstan * fix: wip * fix: wip * fix: wip * fix: wip * fix: allow hours before event to schedule mailator * Fix styling * fix: fixing after or equal Co-authored-by: binaryk <[email protected]>
- Loading branch information
Showing
3 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
namespace Binarcode\LaravelMailator\Tests\Feature; | ||
|
||
use Binarcode\LaravelMailator\Constraints\BeforeConstraint; | ||
use Binarcode\LaravelMailator\Models\MailatorSchedule; | ||
use Binarcode\LaravelMailator\Tests\Fixtures\InvoiceReminderMailable; | ||
use Binarcode\LaravelMailator\Tests\TestCase; | ||
use Illuminate\Support\Facades\Mail; | ||
|
||
class BeforeConstraintTest extends TestCase | ||
{ | ||
public function test_past_target_with_before_now_passed_after_constraint_day_bases(): void | ||
{ | ||
Mail::fake(); | ||
Mail::assertNothingSent(); | ||
|
||
$scheduler = MailatorSchedule::init('Invoice reminder.') | ||
->recipients($mail = '[email protected]') | ||
->mailable( | ||
(new InvoiceReminderMailable())->to('[email protected]') | ||
) | ||
->days(1) | ||
->before(now()->addDays(2)); | ||
|
||
$scheduler->save(); | ||
|
||
$this->travel(1)->days(); | ||
|
||
self::assertFalse( | ||
$scheduler->fresh()->isFutureAction() | ||
); | ||
|
||
$can = app(BeforeConstraint::class)->canSend( | ||
$scheduler, | ||
$scheduler->logs | ||
); | ||
|
||
self::assertTrue( | ||
$can | ||
); | ||
} | ||
|
||
public function test_past_target_with_before_now_passed_after_constraint_hourly_bases(): void | ||
{ | ||
Mail::fake(); | ||
Mail::assertNothingSent(); | ||
|
||
$scheduler = MailatorSchedule::init('Invoice reminder.') | ||
->recipients($mail = '[email protected]') | ||
->mailable( | ||
(new InvoiceReminderMailable())->to('[email protected]') | ||
) | ||
->hours(1) | ||
->before(now()->addHours(3)); | ||
|
||
$scheduler->save(); | ||
|
||
$this->travel(1)->hours(); | ||
|
||
$this->travel(1)->hours(); | ||
|
||
$can = app( | ||
BeforeConstraint::class | ||
)->canSend( | ||
$scheduler, | ||
$scheduler->logs | ||
); | ||
|
||
self::assertTrue( | ||
$can | ||
); | ||
|
||
$this->travel(1)->hours(); | ||
|
||
$can = app( | ||
BeforeConstraint::class | ||
)->canSend( | ||
$scheduler, | ||
$scheduler->logs | ||
); | ||
|
||
self::assertFalse( | ||
$scheduler->fresh()->isFutureAction() | ||
); | ||
|
||
self::assertFalse( | ||
$can | ||
); | ||
} | ||
} |