Saeed Vaziry f70963d6bb
fix notification chanels and more tests (#108)
* fix notification chanels and more tests

* fix code style
2024-02-16 21:10:17 +01:00

84 lines
2.0 KiB
PHP

<?php
namespace Tests\Unit\NotificationChannels;
use App\Mail\NotificationMail;
use App\Models\NotificationChannel;
use App\NotificationChannels\Email;
use Illuminate\Support\Facades\Mail;
use Tests\TestCase;
class EmailTest extends TestCase
{
public function test_create_rules(): void
{
$provider = new Email(NotificationChannel::factory()->create([
'provider' => 'email',
]));
$this->assertSame([
'email' => 'required|email',
], $provider->createRules([]));
}
public function test_create_data(): void
{
$provider = new Email(NotificationChannel::factory()->create([
'provider' => 'email',
]));
$this->assertSame([
'email' => 'user@example.com',
], $provider->createData([
'email' => 'user@example.com',
]));
}
public function test_data(): void
{
$provider = new Email(NotificationChannel::factory()->create([
'provider' => 'email',
'data' => [
'email' => 'user@example.com',
],
]));
$this->assertSame([
'email' => 'user@example.com',
], $provider->data());
}
public function test_connect(): void
{
$provider = new Email(NotificationChannel::factory()->create([
'provider' => 'email',
'data' => [
'email' => 'user@example.com',
],
]));
Mail::fake();
$this->assertTrue($provider->connect());
Mail::assertSent(NotificationMail::class);
}
public function test_send(): void
{
$channel = NotificationChannel::factory()->create([
'provider' => 'email',
'data' => [
'email' => 'user@example.com',
],
]);
$provider = new Email($channel);
Mail::fake();
$provider->send($channel, new TestNotification());
Mail::assertSent(NotificationMail::class);
}
}