mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 10:21:37 +00:00
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
84 lines
2.0 KiB
PHP
84 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\NotificationChannels;
|
|
|
|
use App\Models\NotificationChannel;
|
|
use App\NotificationChannels\Email;
|
|
use App\NotificationChannels\Email\NotificationMail;
|
|
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);
|
|
}
|
|
}
|