100 lines
3.2 KiB
PHP
100 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Invoice;
|
|
|
|
use App\Invoice\InvoiceSettings;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
use Tests\TestCase;
|
|
|
|
class SettingTest extends TestCase
|
|
{
|
|
use DatabaseTransactions;
|
|
|
|
public function testSettingIndex(): void
|
|
{
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
$response = $this->get('/setting/bill')->assertInertiaComponent('setting/Bill')->assertInertia('url', route('settingapilist');
|
|
}
|
|
|
|
public function testItGetsSettingsFromApi(): void
|
|
{
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
InvoiceSettings::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',
|
|
'iban' => 'DE05',
|
|
'bic' => 'SOLSDE',
|
|
'rememberWeeks' => 6
|
|
]);
|
|
|
|
$response = $this->get(route('api.settigs.list'));
|
|
|
|
$response->assertOk();
|
|
$this->assertInertiaHas([
|
|
'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',
|
|
'iban' => 'DE05',
|
|
'bic' => 'SOLSDE',
|
|
'remember_weeks' => 6
|
|
], $response, 'data');
|
|
}
|
|
|
|
public function testItReturnsTabs(): void
|
|
{
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
$response = $this->get('/setting/bill');
|
|
|
|
/** @var array<int, array{url: string, title: 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']);
|
|
}
|
|
|
|
public function testItCanChangeSettings(): void
|
|
{
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
$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',
|
|
'iban' => 'DE05',
|
|
'bic' => 'SOLSDE',
|
|
'remember_weeks' => 10
|
|
]);
|
|
|
|
$response->assertRedirect('/setting/bill');
|
|
$settings = app(InvoiceSettings::class);
|
|
$this->assertEquals('DPSG Stamm Muster', $settings->from_long);
|
|
$this->assertEquals('DE05', $settings->iban);
|
|
$this->assertEquals('SOLSDE', $settings->bic);
|
|
$this->assertEquals(10, $settings->rememberWeeks);
|
|
}
|
|
}
|