2022-09-06 00:36:14 +02:00
|
|
|
<?php
|
|
|
|
|
2022-10-20 02:15:28 +02:00
|
|
|
namespace Tests\Feature\Bill;
|
2022-09-06 00:36:14 +02:00
|
|
|
|
2022-11-07 16:18:11 +01:00
|
|
|
use App\Letter\LetterSettings;
|
2022-09-06 00:36:14 +02:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class SettingTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testSettingIndex(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2022-11-07 16:18:11 +01:00
|
|
|
LetterSettings::fake([
|
2022-09-06 00:36:14 +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-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');
|
|
|
|
}
|
|
|
|
|
2022-10-20 02:15:28 +02:00
|
|
|
public function testItReturnsTabs(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
|
|
|
|
$response = $this->get('/setting/bill');
|
|
|
|
|
|
|
|
/** @var array<int, array{url: string, is_active: bool}> */
|
|
|
|
$menus = $this->inertia($response, 'setting_menu');
|
|
|
|
$this->assertTrue(
|
|
|
|
collect($menus)
|
|
|
|
->pluck('url')
|
|
|
|
->contains('/setting/bill')
|
|
|
|
);
|
|
|
|
|
|
|
|
$settingMenu = collect($menus)->first(fn ($menu) => '/setting/bill' === $menu['url']);
|
|
|
|
$this->assertTrue($settingMenu['is_active']);
|
|
|
|
$this->assertEquals('Rechnung', $settingMenu['title']);
|
|
|
|
}
|
|
|
|
|
2022-09-06 00:36:14 +02:00
|
|
|
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-11-07 16:18:11 +01:00
|
|
|
$settings = app(LetterSettings::class);
|
2022-09-06 00:36:14 +02:00
|
|
|
$this->assertEquals('DPSG Stamm Muster', $settings->from_long);
|
|
|
|
}
|
|
|
|
}
|