268 lines
15 KiB
PHP
268 lines
15 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Member;
|
|
|
|
use App\Activity;
|
|
use App\Confession;
|
|
use App\Country;
|
|
use App\Course\Models\Course;
|
|
use App\Course\Models\CourseMember;
|
|
use App\Gender;
|
|
use App\Group;
|
|
use App\Invoice\BillKind;
|
|
use App\Invoice\Models\Invoice;
|
|
use App\Invoice\Models\InvoicePosition;
|
|
use App\Member\Member;
|
|
use App\Member\MemberResource;
|
|
use App\Member\Membership;
|
|
use App\Nationality;
|
|
use App\Payment\Subscription;
|
|
use App\Region;
|
|
use App\Subactivity;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
uses(DatabaseTransactions::class);
|
|
|
|
beforeEach(function () {
|
|
Country::factory()->create(['name' => 'Deutschland']);
|
|
});
|
|
|
|
mutates(MemberResource::class);
|
|
|
|
it('shows courses', function () {
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
$member = Member::factory()
|
|
->defaults()
|
|
->has(
|
|
CourseMember::factory()
|
|
->for(Course::factory()->name(' Baustein 2e - Gewalt gegen Kinder und Jugendliche: Vertiefung, Prävention '))
|
|
->state(['organizer' => 'DPSG', 'event_name' => 'Wochenende', 'completed_at' => '2022-03-03']),
|
|
'courses'
|
|
)
|
|
->create();
|
|
|
|
$this->get("/member/{$member->id}")
|
|
->assertInertiaPath('data.courses.0.organizer', 'DPSG')
|
|
->assertInertiaPath('data.courses.0.event_name', 'Wochenende')
|
|
->assertInertiaPath('data.courses.0.completed_at_human', '03.03.2022')
|
|
->assertInertiaPath('data.courses.0.course.name', ' Baustein 2e - Gewalt gegen Kinder und Jugendliche: Vertiefung, Prävention ')
|
|
->assertInertiaPath('data.courses.0.course.short_name', '2e');
|
|
});
|
|
|
|
it('shows default', function () {
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
$activity = Activity::factory()->name('€ Mitglied')->create();
|
|
$subactivity = Subactivity::factory()->name('Jungpfadfinder')->create();
|
|
$activity->subactivities()->attach($subactivity);
|
|
$course = Course::factory()->name('LL')->create();
|
|
$region = Region::factory()->name('LLa')->create();
|
|
$member = Member::factory()->male()->defaults()->create();
|
|
|
|
$this->get("/member/{$member->id}")
|
|
->assertInertiaPath('meta.default.address', '')
|
|
->assertInertiaPath('meta.filterActivities.0.name', '€ Mitglied')
|
|
->assertInertiaPath('meta.filterActivities.0.id', $activity->id)
|
|
->assertInertiaPath('meta.filterSubactivities.0.name', 'Jungpfadfinder')
|
|
->assertInertiaPath('meta.filterSubactivities.0.id', $subactivity->id)
|
|
->assertInertiaPath('meta.formActivities.0.name', '€ Mitglied')
|
|
->assertInertiaPath('meta.formActivities.0.id', $activity->id)
|
|
->assertInertiaPath("meta.formSubactivities.{$activity->id}.{$subactivity->id}", "Jungpfadfinder")
|
|
->assertInertiaPath('meta.default.has_nami', false)
|
|
->assertInertiaPath('meta.default.send_newspaper', false)
|
|
->assertInertiaPath('meta.groups.0.id', $member->group->id)
|
|
->assertInertiaPath('meta.default.fax', '')
|
|
->assertInertiaPath('meta.filter.search', '')
|
|
->assertInertiaPath('meta.billKinds.0.id', 'E-Mail')
|
|
->assertInertiaPath('meta.courses.0.id', $course->id)
|
|
->assertInertiaPath('meta.courses.0.name', 'LL')
|
|
->assertInertiaPath('meta.regions.0.name', 'LLa')
|
|
->assertInertiaPath('meta.regions.0.id', $region->id)
|
|
->assertInertiaPath('meta.subscriptions.0.id', $member->subscription->id)
|
|
->assertInertiaPath('meta.subscriptions.0.name', $member->subscription->name)
|
|
->assertInertiaPath('meta.links.create', route('member.create'))
|
|
->assertInertiaPath('meta.links.index', route('member.index'))
|
|
->assertInertiaPath('meta.countries.0.id', $member->country->id)
|
|
->assertInertiaPath('meta.countries.0.name', $member->country->name)
|
|
->assertInertiaPath('meta.genders.0.id', $member->gender->id)
|
|
->assertInertiaPath('meta.genders.0.name', $member->gender->name)
|
|
->assertInertiaPath('meta.default.bank_account.iban', '')
|
|
->assertInertiaPath('meta.default_membership_filter.group_ids', [])
|
|
->assertInertiaPath('meta.default_membership_filter.activity_ids', [])
|
|
->assertInertiaPath('meta.default_membership_filter.subactivity_ids', [])
|
|
->assertInertiaPath('meta.default.bank_account.bic', '')
|
|
->assertInertiaPath('meta.default.bank_account.blz', '')
|
|
->assertInertiaPath('meta.default.bank_account.bank_name', '')
|
|
->assertInertiaPath('meta.default.bank_account.person', '')
|
|
->assertInertiaPath('meta.default.bank_account.account_number', '')
|
|
->assertInertiaPath('meta.default.letter_address', '')
|
|
->assertInertiaPath('meta.default.email', '')
|
|
->assertInertiaPath('meta.default.has_vk', false)
|
|
->assertInertiaPath('meta.default.has_svk', false)
|
|
->assertInertiaPath('meta.default.multiply_pv', false)
|
|
->assertInertiaPath('meta.default.multiply_more_pv', false)
|
|
->assertInertiaPath('meta.default.email_parents', '')
|
|
->assertInertiaPath('meta.default.children_phone', '')
|
|
->assertInertiaPath('meta.default.work_phone', '')
|
|
->assertInertiaPath('meta.default.mobile_phone', '')
|
|
->assertInertiaPath('meta.default.main_phone', '')
|
|
->assertInertiaPath('meta.default.other_country', '')
|
|
->assertInertiaPath('meta.default.birthday', '')
|
|
->assertInertiaPath('meta.default.location', '')
|
|
->assertInertiaPath('meta.default.zip', '')
|
|
->assertInertiaPath('meta.default.address', '')
|
|
->assertInertiaPath('meta.default.further_address', '')
|
|
->assertInertiaPath('meta.default.firstname', '')
|
|
->assertInertiaPath('meta.default.comment', '')
|
|
->assertInertiaPath('meta.default.joined_at', now()->format('Y-m-d'))
|
|
->assertInertiaPath('meta.default.lastname', '')
|
|
->assertInertiaPath('meta.default.ps_at', null)
|
|
->assertInertiaPath('meta.default.more_ps_at', null)
|
|
->assertInertiaPath('meta.default.without_education_at', null)
|
|
->assertInertiaPath('meta.default.without_efz_at', null)
|
|
->assertInertiaPath('meta.default.efz', null);
|
|
});
|
|
|
|
it('shows efz link', function () {
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
$member = Member::factory()->defaults()->create();
|
|
|
|
$this->get("/member/{$member->id}")
|
|
->assertInertiaPath('data.efz_link', route('efz', $member));
|
|
});
|
|
|
|
it('shows memberships', function () {
|
|
Carbon::setTestNow(Carbon::parse('2006-01-01 15:00:00'));
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
$member = Member::factory()
|
|
->defaults()
|
|
->for(Group::factory()->name('Stamm Beispiel'))
|
|
->has(Membership::factory()->promise(now())->in('€ LeiterIn', 5, 'Jungpfadfinder', 88)->from('2005-11-19'))
|
|
->create();
|
|
|
|
$this->get("/member/{$member->id}")
|
|
->assertInertiaPath('data.age_group_icon', 'jungpfadfinder')
|
|
->assertInertiaPath('data.is_leader', true)
|
|
->assertInertiaPath('data.memberships.0.id', $member->memberships->first()->id)
|
|
->assertInertiaPath('data.memberships.0.from.human', '19.11.2005')
|
|
->assertInertiaPath('data.memberships.0.from.raw', '2005-11-19')
|
|
->assertInertiaPath('data.memberships.0.promised_at.human', now()->format('d.m.Y'))
|
|
->assertInertiaPath('data.memberships.0.promised_at.raw', now()->format('Y-m-d'))
|
|
->assertInertiaPath('data.memberships.0.activity.name', '€ LeiterIn')
|
|
->assertInertiaPath('data.memberships.0.activity.id', $member->memberships->first()->activity->id)
|
|
->assertInertiaPath('data.memberships.0.subactivity.name', 'Jungpfadfinder')
|
|
->assertInertiaPath('data.memberships.0.subactivity.id', $member->memberships->first()->subactivity->id);
|
|
});
|
|
|
|
it('shows that member is not a leader', function () {
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
$member = Member::factory()->defaults()->create();
|
|
|
|
$this->get("/member/{$member->id}")
|
|
->assertInertiaPath('data.is_leader', false);
|
|
});
|
|
|
|
it('shows links', function () {
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
$member = Member::factory()->defaults()->create();
|
|
|
|
$this->get("/member/{$member->id}")
|
|
->assertInertiaPath('data.links.edit', route('member.edit', $member))
|
|
->assertInertiaPath('data.links.show', route('member.show', $member))
|
|
->assertInertiaPath('data.links.invoiceposition_index', route('member.invoice-position.index', $member))
|
|
->assertInertiaPath('data.links.membership_index', route('member.membership.index', $member))
|
|
->assertInertiaPath('data.links.course_index', route('member.course.index', $member));
|
|
});
|
|
|
|
it('shows invoice positions', function () {
|
|
Carbon::setTestNow(Carbon::parse('2006-01-01 15:00:00'));
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
$member = Member::factory()
|
|
->defaults()
|
|
->has(InvoicePosition::factory()->for(Invoice::factory())->price(1050)->description('uu'))
|
|
->create();
|
|
|
|
$this->get("/member/{$member->id}")
|
|
->assertInertiaPath('data.pending_payment', '10,50 €')
|
|
->assertInertiaPath('data.invoicePositions.0.description', 'uu')
|
|
->assertInertiaPath('data.invoicePositions.0.price_human', '10,50 €')
|
|
->assertInertiaPath('data.invoicePositions.0.invoice.status', 'Neu');
|
|
});
|
|
|
|
it('shows member single', function (array $attributes, array $expect) {
|
|
Carbon::setTestNow(Carbon::parse('2006-01-01 15:00:00'));
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
$member = Member::factory()
|
|
->for(Group::factory())
|
|
->for(Nationality::factory()->name('deutsch'))
|
|
->for(Subscription::factory()->forFee())
|
|
->create($attributes);
|
|
|
|
$this->get("/member/{$member->id}")
|
|
->assertInertiaPath('data.id', $member->id)
|
|
->assertInertiaPathArray($expect);
|
|
})->with([
|
|
fn() => [['region_id' => Region::factory()->name('UUU')->create()->id], ['data.region.name' => 'UUU', 'data.region.id' => Region::first()->id, 'data.region_id' => Region::first()->id]],
|
|
fn() => [['confession_id' => Confession::factory()->create(['name' => 'UUU'])->id], ['data.confession_id' => Confession::firstWhere('name', 'UUU')->id]],
|
|
fn() => [['nationality_id' => Nationality::factory()->name('UUU')->create()->id], ['data.nationality.name' => 'UUU', 'data.nationality_id' => Nationality::first()->id, 'data.nationality.id' => Nationality::first()->id]],
|
|
fn() => [['group_id' => Group::factory()->name('UUU')->create()->id], ['data.group_name' => 'UUU', 'data.group_id' => Group::firstWhere('name', 'UUU')->id]],
|
|
fn() => [['bill_kind' => BillKind::EMAIL->value], ['data.bill_kind_name' => 'E-Mail', 'data.bill_kind' => 'E-Mail']],
|
|
fn() => [['subscription_id' => Subscription::factory()->name('Sub')->forFee()->create()], ['data.subscription.name' => 'Sub', 'data.subscription_id' => Subscription::first()->id]],
|
|
fn() => [['country_id' => Country::factory()->create(['name' => 'Sub'])->id], ['data.country_id' => Country::firstWhere('name', 'Sub')->id]],
|
|
fn() => [['firstname' => 'Max', 'lastname' => 'Muster', 'gender_id' => Gender::factory()->male()->create()->id], ['data.firstname' => 'Max', 'data.lastname' => 'Muster', 'data.fullname' => 'Herr Max Muster', 'data.gender_id' => Gender::first()->id]],
|
|
[['firstname' => 'Max', 'lastname' => 'Muster', 'gender_id' => null], ['data.fullname' => 'Max Muster']],
|
|
[['other_country' => 'other', 'further_address' => 'other', 'letter_address' => 'A'], ['data.other_country' => 'other', 'data.further_address' => 'other', 'data.letter_address' => 'A']],
|
|
[['gender_id' => null], ['data.gender_name' => 'keine Angabe']],
|
|
[['salutation' => 'Dr'], ['data.salutation' => 'Dr']],
|
|
[['comment' => 'Com'], ['data.comment' => 'Com']],
|
|
[['birthday' => null], ['data.birthday' => null, 'data.birthday_human' => null]],
|
|
[[], ['data.bank_account.iban' => null]],
|
|
[
|
|
['efz' => null, 'ps_at' => null, 'ps_at' => null, 'more_ps_at' => null, 'has_svk' => false, 'has_vk' => false, 'has_svk' => true],
|
|
['data.efz_human' => null, 'data.ps_at_human' => null, 'data.ps_at_human' => null, 'data.more_ps_at_human' => null, 'data.has_svk' => false, 'data.has_vk' => false, 'data.has_svk' => true]
|
|
],
|
|
[
|
|
['has_vk' => true, 'multiply_more_pv' => false, 'without_efz_at' => null, 'without_education_at' => null],
|
|
['data.has_vk' => true, 'data.multiply_more_pv' => false, 'data.without_efz_at_human' => null, 'data.without_education_at_human' => null]
|
|
],
|
|
[
|
|
['main_phone' => '+49 212 1266775', 'mobile_phone' => '+49 212 1266776', 'work_phone' => '+49 212 1266777', 'children_phone' => '+49 212 1266778'],
|
|
['data.main_phone' => '+49 212 1266775', 'data.mobile_phone' => '+49 212 1266776', 'data.work_phone' => '+49 212 1266777', 'data.children_phone' => '+49 212 1266778']
|
|
],
|
|
[
|
|
['efz' => '2022-09-20', 'ps_at' => '2022-04-20', 'more_ps_at' => '2022-06-02', 'without_education_at' => '2022-06-03', 'without_efz_at' => '2022-06-04'],
|
|
['data.efz' => '2022-09-20', 'data.efz_human' => '20.09.2022', 'data.ps_at' => '2022-04-20', 'data.more_ps_at' => '2022-06-02', 'data.without_education_at' => '2022-06-03', 'data.without_efz_at' => '2022-06-04', 'data.ps_at_human' => '20.04.2022', 'data.more_ps_at_human' => '02.06.2022', 'data.without_education_at_human' => '03.06.2022', 'data.without_efz_at_human' => '04.06.2022']
|
|
],
|
|
[['recertified_at' => '2022-06-13'], ['data.recertified_at_human' => '13.06.2022', 'data.recertified_at' => '2022-06-13']],
|
|
[['multiply_pv' => true, 'multiply_more_pv' => true], ['data.multiply_pv' => true, 'data.multiply_more_pv' => true]],
|
|
[
|
|
['email' => 'a@b.de', 'email_parents' => 'b@c.de', 'fax' => '+49 212 1255674'],
|
|
['data.email' => 'a@b.de', 'data.email_parents' => 'b@c.de', 'data.fax' => '+49 212 1255674']
|
|
],
|
|
[['nami_id' => 123], ['data.nami_id' => 123, 'data.has_nami' => true]],
|
|
[['send_newspaper' => true], ['data.send_newspaper' => true]],
|
|
[['address' => 'Itterstr 3', 'location' => 'Solingen', 'zip' => '42719'], ['data.location' => 'Solingen', 'data.address' => 'Itterstr 3', 'data.zip' => '42719', 'data.full_address' => 'Itterstr 3, 42719 Solingen']],
|
|
[['lon' => 19.05, 'lat' => 14.053], ['data.lon' => 19.05, 'data.lat' => 14.053]],
|
|
[['birthday' => '1991-04-20'], ['data.birthday' => '1991-04-20', 'data.birthday_human' => '20.04.1991', 'data.age' => 14]],
|
|
[['joined_at' => '2022-06-11'], ['data.joined_at' => '2022-06-11', 'data.joined_at_human' => '11.06.2022']],
|
|
[['mitgliedsnr' => 998, 'keepdata' => true], ['data.mitgliedsnr' => 998, 'data.keepdata' => true]],
|
|
]);
|
|
|
|
it('testItShowsIfMembershipIsActive', function (Carbon $from, ?Carbon $to, bool $isActive) {
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
$member = Member::factory()
|
|
->defaults()
|
|
->has(Membership::factory()->in('€ LeiterIn', 455, 'Pfadfinder', 15)->state(['from' => $from, 'to' => $to]))
|
|
->create();
|
|
|
|
$response = $this->get("/member/{$member->id}");
|
|
|
|
$this->assertInertiaHas($isActive, $response, 'data.memberships.0.is_active');
|
|
})->with([
|
|
[now()->subMonths(2), null, true],
|
|
[now()->subMonths(2), now()->subDay(), false],
|
|
[now()->addDays(2), null, false],
|
|
]);
|