adrema/modules/Mailgateway/IndexTest.php

39 lines
1.4 KiB
PHP
Raw Normal View History

2024-10-20 21:19:07 +02:00
<?php
namespace Tests\Feature\Mailgateway;
use App\Mailgateway\Models\Mailgateway;
use App\Mailgateway\Types\LocalType;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Livewire\Livewire;
use Modules\Mailgateway\Components\SettingView;
use Tests\RequestFactories\MailmanTypeRequest;
use Tests\TestCase;
uses(DatabaseTransactions::class);
uses(TestCase::class);
it('test it can view index page', function () {
test()->login()->loginNami();
test()->get('/setting/mailgateway')->assertSeeLivewire(SettingView::class);
});
it('test it displays local gateways', function () {
test()->withoutExceptionHandling()->login()->loginNami();
2024-10-23 21:02:42 +02:00
Mailgateway::factory()->type(LocalType::from([]))->name('Lore')->domain('example.com')->create();
2024-10-20 21:19:07 +02:00
Livewire::test(SettingView::class)
->assertSeeHtml('example.com')
->assertSeeHtml('Lore')
->assertSeeHtml('Lokal')
->assertSeeHtml('Verbindung erfolgreich');
});
it('displays mailman gateways', function () {
test()->withoutExceptionHandling()->login()->loginNami();
2024-10-23 21:02:42 +02:00
$typeParams = MailmanTypeRequest::new()->succeeds()->state(['url' => 'https://mailman.example.com', 'user' => 'user', 'password' => 'password', 'owner' => 'owner']);
Mailgateway::factory()->type($typeParams->toData())->create();
2024-10-20 21:19:07 +02:00
Livewire::test(SettingView::class)->assertSeeHtml('Verbindung erfolgreich');
});