adrema/tests/Feature/Setting/SettingTest.php

62 lines
1.8 KiB
PHP
Raw Normal View History

2022-09-06 00:36:14 +02:00
<?php
namespace Tests\Feature\Setting;
use App\Setting\BillSettings;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class SettingTest extends TestCase
{
use DatabaseTransactions;
public function testSettingIndex(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
BillSettings::fake([
'from_long' => 'DPSG Stamm Muster',
'from' => 'Stamm Muster',
'mobile' => '+49 176 55555',
'email' => 'max@muster.de',
'website' => 'https://example.com',
'address' => 'Musterstr 4',
'place' => 'Solingen',
'zip' => '12345',
]);
2022-10-18 14:28:46 +02:00
$response = $this->get('/setting/bill');
2022-09-06 00:36:14 +02:00
$response->assertOk();
$this->assertInertiaHas([
2022-10-18 14:28:46 +02:00
'from_long' => 'DPSG Stamm Muster',
'from' => 'Stamm Muster',
'mobile' => '+49 176 55555',
'email' => 'max@muster.de',
'website' => 'https://example.com',
'address' => 'Musterstr 4',
'place' => 'Solingen',
'zip' => '12345',
2022-09-06 00:36:14 +02:00
], $response, 'data');
}
public function testItCanChangeSettings(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
2022-10-18 14:28:46 +02:00
$response = $this->from('/setting/bill')->post('/setting/bill', [
'from_long' => 'DPSG Stamm Muster',
'from' => 'Stamm Muster',
'mobile' => '+49 176 55555',
'email' => 'max@muster.de',
'website' => 'https://example.com',
'address' => 'Musterstr 4',
'place' => 'Solingen',
'zip' => '12345',
2022-09-06 00:36:14 +02:00
]);
2022-10-18 14:28:46 +02:00
$response->assertRedirect('/setting/bill');
2022-09-06 00:36:14 +02:00
$settings = app(BillSettings::class);
$this->assertEquals('DPSG Stamm Muster', $settings->from_long);
}
}