mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 06:26:16 +00:00
fix notification chanels and more tests (#108)
* fix notification chanels and more tests * fix code style
This commit is contained in:
83
tests/Unit/NotificationChannels/EmailTest.php
Normal file
83
tests/Unit/NotificationChannels/EmailTest.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user