2024-06-28 16:13:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Notifications;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Notifications\TestEmailSettingNotification;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
|
|
use Tests\FeatureTestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TestEmailSettingNotificationTest test class
|
|
|
|
*/
|
|
|
|
#[CoversClass(TestEmailSettingNotification::class)]
|
|
|
|
class TestEmailSettingNotificationTest extends FeatureTestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \App\Models\User
|
|
|
|
*/
|
|
|
|
protected $user;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \App\Notifications\TestEmailSettingNotification
|
|
|
|
*/
|
|
|
|
protected $testEmailSettingNotification;
|
|
|
|
|
|
|
|
public function setUp() : void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2024-09-26 23:50:01 +02:00
|
|
|
$this->user = User::factory()->create();
|
2024-06-28 16:13:45 +02:00
|
|
|
$this->testEmailSettingNotification = new TestEmailSettingNotification('test_token');
|
|
|
|
}
|
|
|
|
|
|
|
|
#[Test]
|
|
|
|
public function test_it_renders_to_email()
|
|
|
|
{
|
|
|
|
$mail = $this->testEmailSettingNotification->toMail($this->user);
|
|
|
|
|
|
|
|
$this->assertInstanceOf(MailMessage::class, $mail);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[Test]
|
|
|
|
public function test_rendered_email_contains_expected_data()
|
|
|
|
{
|
|
|
|
$mail = $this->testEmailSettingNotification->toMail($this->user)->render();
|
|
|
|
|
|
|
|
$this->assertStringContainsString(
|
|
|
|
__('notifications.test_email_settings.success'),
|
|
|
|
$mail
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|