actingAs(User::factory()->admin()->create()); Livewire::test('shared::company') ->set('name', 'Mediatalo Oy') ->set('business_id', '737546-2') ->set('address', "Kauppakatu 1\n40100 Jyväskylä") ->set('email', 'INFO@example.fi') ->call('save') ->assertHasNoErrors() ->assertSet('business_id', '0737546-2') ->assertSet('statusMessage', __('company.saved')); $details = app(CompanyDetailsStore::class)->get(); expect($details->name)->toBe('Mediatalo Oy') ->and($details->email)->toBe('info@example.fi') ->and($details->phone)->toBeNull() ->and($details->vatNumber())->toBe('FI07375462'); Livewire::test('shared::company')->assertSet('name', 'Mediatalo Oy'); }); it('rejects an invalid business ID and email address', function () { $this->actingAs(User::factory()->admin()->create()); Livewire::test('shared::company') ->set('name', 'Mediatalo Oy') ->set('business_id', '1234567-8') ->call('save') ->assertHasErrors(['business_id' => [__('company.errors.business_id')]]) ->set('business_id', '0737546-2') ->set('email', 'ei-osoite') ->call('save') ->assertHasErrors(['email' => [__('company.errors.email')]]); expect(app(CompanyDetailsStore::class)->get())->toBeNull(); }); it('keeps everyone but the admin out', function () { $this->actingAs(User::factory()->management()->create()); $this->get(route('settings.company'))->assertForbidden(); });