2022-09-06 00:36:14 +02:00
|
|
|
<?php
|
|
|
|
|
2023-06-01 12:04:31 +02:00
|
|
|
namespace Tests\Feature\Invoice;
|
2022-09-06 00:36:14 +02:00
|
|
|
|
2023-04-18 22:08:45 +02:00
|
|
|
use App\Invoice\InvoiceSettings;
|
2022-09-06 00:36:14 +02:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class SettingTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
2024-08-01 13:33:28 +02:00
|
|
|
public function testItDisplaysView(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
|
|
|
|
$this->get(route('setting.view', ['settingGroup' => 'bill']))
|
|
|
|
->assertOk()
|
|
|
|
->assertComponent('setting/Bill');
|
|
|
|
}
|
|
|
|
|
2024-08-01 10:25:48 +02:00
|
|
|
public function testDisplaySettings(): void
|
2022-09-06 00:36:14 +02:00
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2024-08-01 10:25:48 +02:00
|
|
|
app(InvoiceSettings::class)->fill([
|
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-11-17 23:59:43 +01:00
|
|
|
'iban' => 'DE05',
|
|
|
|
'bic' => 'SOLSDE',
|
2024-07-31 21:37:18 +02:00
|
|
|
'rememberWeeks' => 6
|
2024-08-01 10:25:48 +02:00
|
|
|
])->save();
|
2022-09-06 00:36:14 +02:00
|
|
|
|
2024-08-01 13:33:28 +02:00
|
|
|
$this->get(route('setting.data', ['settingGroup' => 'bill']))
|
2024-08-01 10:25:48 +02:00
|
|
|
->assertOk()
|
|
|
|
->assertComponent('setting/Bill')
|
|
|
|
->assertInertiaPath('data.from_long', 'DPSG Stamm Muster')
|
|
|
|
->assertInertiaPath('data.from', 'Stamm Muster')
|
|
|
|
->assertInertiaPath('data.mobile', '+49 176 55555')
|
|
|
|
->assertInertiaPath('data.email', 'max@muster.de')
|
|
|
|
->assertInertiaPath('data.website', 'https://example.com')
|
|
|
|
->assertInertiaPath('data.address', 'Musterstr 4')
|
|
|
|
->assertInertiaPath('data.place', 'Solingen')
|
|
|
|
->assertInertiaPath('data.zip', '12345')
|
|
|
|
->assertInertiaPath('data.iban', 'DE05')
|
|
|
|
->assertInertiaPath('data.bic', 'SOLSDE')
|
2024-08-01 13:33:28 +02:00
|
|
|
->assertInertiaPath('data.rememberWeeks', 6);
|
2022-09-06 00:36:14 +02:00
|
|
|
}
|
|
|
|
|
2022-10-20 02:15:28 +02:00
|
|
|
public function testItReturnsTabs(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
|
2024-08-01 13:33:28 +02:00
|
|
|
$this->get(route('setting.view', ['settingGroup' => 'bill']))
|
2024-08-01 10:25:48 +02:00
|
|
|
->assertInertiaPath('setting_menu.1.title', 'Rechnung')
|
2024-08-01 13:33:28 +02:00
|
|
|
->assertInertiaPath('setting_menu.1.url', url('/setting/bill'))
|
2024-08-01 10:25:48 +02:00
|
|
|
->assertInertiaPath('setting_menu.1.is_active', true)
|
|
|
|
->assertInertiaPath('setting_menu.0.is_active', false);
|
2022-10-20 02:15:28 +02:00
|
|
|
}
|
|
|
|
|
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-11-17 23:59:43 +01:00
|
|
|
'iban' => 'DE05',
|
|
|
|
'bic' => 'SOLSDE',
|
2024-08-01 13:33:28 +02:00
|
|
|
'rememberWeeks' => 10
|
2022-09-06 00:36:14 +02:00
|
|
|
]);
|
|
|
|
|
2022-10-18 14:28:46 +02:00
|
|
|
$response->assertRedirect('/setting/bill');
|
2023-04-18 22:08:45 +02:00
|
|
|
$settings = app(InvoiceSettings::class);
|
2022-09-06 00:36:14 +02:00
|
|
|
$this->assertEquals('DPSG Stamm Muster', $settings->from_long);
|
2022-11-17 23:59:43 +01:00
|
|
|
$this->assertEquals('DE05', $settings->iban);
|
|
|
|
$this->assertEquals('SOLSDE', $settings->bic);
|
2024-07-31 21:37:18 +02:00
|
|
|
$this->assertEquals(10, $settings->rememberWeeks);
|
2022-09-06 00:36:14 +02:00
|
|
|
}
|
|
|
|
}
|