adrema/tests/Feature/Invoice/SettingTest.php

89 lines
2.8 KiB
PHP
Raw Normal View History

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;
public function testSettingIndex(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
2023-04-18 22:08:45 +02:00
InvoiceSettings::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-11-17 23:59:43 +01:00
'iban' => 'DE05',
'bic' => 'SOLSDE',
2022-09-06 00:36:14 +02:00
]);
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-11-17 23:59:43 +01:00
'iban' => 'DE05',
'bic' => 'SOLSDE',
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');
2023-02-17 18:57:11 +01:00
/** @var array<int, array{url: string, title: string, is_active: bool}> */
2022-10-20 02:15:28 +02:00
$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-11-17 23:59:43 +01:00
'iban' => 'DE05',
'bic' => 'SOLSDE',
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);
2022-09-06 00:36:14 +02:00
}
}