create(['name' => 'Deutschland']); }); covers(MemberResource::class); covers(MembershipData::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 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('2022-11-19')) ->create(); $this->get("/member/{$member->id}") ->assertInertiaPath('data.memberships.0.id', $member->memberships->first()->id) ->assertInertiaPath('data.memberships.0.from.human', '19.11.2022') ->assertInertiaPath('data.memberships.0.from.raw', '2022-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 invoice positions', 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(InvoicePosition::factory()->for(Invoice::factory())->price(1050)->description('uu')) ->create(); $this->get("/member/{$member->id}") ->assertInertiaPath('data.invoicePositions.0.description', 'uu') ->assertInertiaPath('data.invoicePositions.0.price_human', '10,50 €') ->assertInertiaPath('data.invoicePositions.0.invoice.status', 'Neu'); }); it('shows member', 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]], 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']], fn() => [['bill_kind' => BillKind::EMAIL->value], ['data.bill_kind_name' => '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'], ['data.other_country' => 'other']], [['further_address' => 'other'], ['data.further_address' => 'other']], [['gender_id' => null], ['data.gender_name' => 'keine Angabe']], [['birthday' => null], ['data.birthday' => null, 'data.birthday_human' => null]], [['efz' => null], ['data.efz_human' => null]], [['ps_at' => null], ['data.ps_at_human' => null]], [['ps_at' => null], ['data.ps_at_human' => null]], [['more_ps_at' => null], ['data.more_ps_at_human' => null]], [['has_svk' => false], ['data.has_svk' => false]], [['has_vk' => false], ['data.has_vk' => false]], [['has_svk' => true], ['data.has_svk' => true]], [['has_vk' => true], ['data.has_vk' => true]], [['multiply_more_pv' => false], ['data.multiply_more_pv' => false]], [['without_efz_at' => null], ['data.without_efz_at_human' => null]], [['without_education_at' => null], ['data.without_education_at_human' => null]], [['main_phone' => '+49 212 1266775'], ['data.main_phone' => '+49 212 1266775']], [['mobile_phone' => '+49 212 1266776'], ['data.mobile_phone' => '+49 212 1266776']], [['work_phone' => '+49 212 1266777'], ['data.work_phone' => '+49 212 1266777']], [['children_phone' => '+49 212 1266778'], ['data.children_phone' => '+49 212 1266778']], [['efz' => '2022-09-20'], ['data.efz_human' => '20.09.2022']], [['ps_at' => '2022-04-20'], ['data.ps_at_human' => '20.04.2022']], [['more_ps_at' => '2022-06-02'], ['data.more_ps_at_human' => '02.06.2022']], [['without_education_at' => '03.06.2022'], ['data.without_education_at_human' => '03.06.2022']], [['without_efz_at' => '2022-06-04'], ['data.without_efz_at_human' => '04.06.2022']], [['recertified_at' => '2022-06-13'], ['data.recertified_at_human' => '13.06.2022']], [['multiply_pv' => true], ['data.multiply_pv' => true]], [['multiply_more_pv' => true], ['data.multiply_more_pv' => true]], [['email' => 'a@b.de'], ['data.email' => 'a@b.de']], [['email_parents' => 'b@c.de'], ['data.email_parents' => 'b@c.de']], [['fax' => '+49 212 1255674'], ['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], ['data.lon' => 19.05]], [['lat' => 14.053], ['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], ['data.mitgliedsnr' => 998]], ]); 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], ]);