2024-07-04 21:01:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Prevention;
|
|
|
|
|
|
|
|
use App\Prevention\PreventionSettings;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\RequestFactories\EditorRequestFactory;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class SettingTest extends TestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testItOpensSettingsPage(): void
|
|
|
|
{
|
|
|
|
$this->login()->loginNami();
|
|
|
|
|
2024-07-04 23:54:37 +02:00
|
|
|
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData();
|
2024-07-04 21:01:14 +02:00
|
|
|
app(PreventionSettings::class)->fill(['formmail' => $text])->save();
|
|
|
|
|
2024-08-01 17:30:55 +02:00
|
|
|
$this->get(route('setting.view', ['settingGroup' => 'prevention']))
|
|
|
|
->assertOk()
|
|
|
|
->assertComponent('setting/Prevention')
|
|
|
|
->assertInertiaPath('data.formmail.blocks.0.data.text', 'lorem ipsum')
|
|
|
|
->assertInertiaPath('store_url', route('setting.store', ['settingGroup' => 'prevention']));
|
2024-07-04 21:01:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testItStoresSettings(): void
|
|
|
|
{
|
|
|
|
$this->login()->loginNami();
|
|
|
|
|
2024-08-01 17:30:55 +02:00
|
|
|
$route = route('setting.store', ['settingGroup' => 'prevention']);
|
|
|
|
$this
|
|
|
|
->from($route)
|
|
|
|
->post($route, ['formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create()])
|
|
|
|
->assertRedirect($route);
|
2024-07-04 23:54:37 +02:00
|
|
|
$this->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
|
2024-07-04 21:01:14 +02:00
|
|
|
}
|
|
|
|
}
|