withoutExceptionHandling()->login()->loginNami(); Member::factory()->defaults()->count(2)->create(['firstname' => 'Alexander']); Member::factory()->defaults()->create(['firstname' => 'Heinrich']); sleep(1); $this->callFilter('member.index', ['search' => 'Alexander']) ->assertInertiaCount('data.data', 2); $this->callFilter('member.index', ['search' => 'Heinrich']) ->assertInertiaCount('data.data', 1); } public function testItHandlesAddress(): void { $this->withoutExceptionHandling()->login()->loginNami(); Member::factory()->defaults()->create(['address' => '']); Member::factory()->defaults()->create(['zip' => '']); Member::factory()->defaults()->create(['location' => '']); Member::factory()->defaults()->create(); sleep(1); $this->callFilter('member.index', ['has_full_address' => false]) ->assertInertiaCount('data.data', 3) ->assertInertiaPath('data.meta.total', 3) ->assertInertiaPath('data.meta.from', 1) ->assertInertiaPath('data.meta.to', 3); $this->callFilter('member.index', ['has_full_address' => true]) ->assertInertiaCount('data.data', 1) ->assertInertiaPath('data.meta.total', 1) ->assertInertiaPath('data.meta.from', 1) ->assertInertiaPath('data.meta.to', 1); } public function testItHandlesBirthday(): void { $this->withoutExceptionHandling()->login()->loginNami(); Member::factory()->defaults()->create(['birthday' => null]); Member::factory()->defaults()->count(2)->create(); sleep(1); $this->callFilter('member.index', ['has_birthday' => true]) ->assertInertiaCount('data.data', 2); $this->callFilter('member.index', ['has_birthday' => false]) ->assertInertiaCount('data.data', 1); } public function testItHandlesBillKind(): void { $this->withoutExceptionHandling()->login()->loginNami(); Member::factory()->defaults()->postBillKind()->create(); Member::factory()->defaults()->emailBillKind()->count(2)->create(); sleep(1); $this->callFilter('member.index', ['bill_kind' => BillKind::POST->value]) ->assertInertiaCount('data.data', 1); $this->callFilter('member.index', ['bill_kind' => BillKind::EMAIL->value]) ->assertInertiaCount('data.data', 2); $this->callFilter('member.index', []) ->assertInertiaCount('data.data', 3); } public function testItHandlesGroupIds(): void { $this->withoutExceptionHandling()->login()->loginNami(); $group = Group::factory()->create(); $otherGroup = Group::factory()->create(); $thirdGroup = Group::factory()->create(); Member::factory()->defaults()->for($group)->create(); Member::factory()->defaults()->count(2)->for($otherGroup)->create(); Member::factory()->defaults()->count(3)->for($thirdGroup)->create(); sleep(1); $this->callFilter('member.index', ['group_ids' => [$group->id]]) ->assertInertiaCount('data.data', 1); $this->callFilter('member.index', ['group_ids' => [$otherGroup->id]]) ->assertInertiaCount('data.data', 2); $this->callFilter('member.index', ['group_ids' => [$otherGroup->id, $thirdGroup->id]]) ->assertInertiaCount('data.data', 5); $this->callFilter('member.index', []) ->assertInertiaCount('data.data', 6); } public function testItHandlesActivitiesAndSubactivities(): void { $this->withoutExceptionHandling()->login()->loginNami(); $mitglied = Activity::factory()->name('€ Mitglied')->create(); $schnuppermitglied = Activity::factory()->name('Schnuppermitgliedschaft')->create(); $woelfling = Subactivity::factory()->name('Wölfling')->create(); $rover = Subactivity::factory()->name('Rover')->create(); Member::factory()->defaults()->create(); Member::factory()->defaults()->count(2)->has(Membership::factory()->for($mitglied)->for($woelfling))->create(); Member::factory()->defaults()->count(3)->has(Membership::factory()->for($schnuppermitglied)->for($rover))->create(); sleep(1); $this->callFilter('member.index', ['activity_ids' => [$mitglied->id]]) ->assertInertiaCount('data.data', 2); $this->callFilter('member.index', ['subactivity_ids' => [$woelfling->id]]) ->assertInertiaCount('data.data', 2); $this->callFilter('member.index', ['subactivity_ids' => [$rover->id]]) ->assertInertiaCount('data.data', 3); $this->callFilter('member.index', ['activity_ids' => [$schnuppermitglied->id], 'subactivity_ids' => [$woelfling->id]]) ->assertInertiaCount('data.data', 0); $this->callFilter('member.index', ['activity_ids' => [$schnuppermitglied->id], 'subactivity_ids' => [$rover->id]]) ->assertInertiaCount('data.data', 3); $this->callFilter('member.index', []) ->assertInertiaCount('data.data', 6); } public function testItHandlesActivityAndSubactivityForSingleMembership(): void { $this->withoutExceptionHandling()->login()->loginNami(); $mitglied = Activity::factory()->name('€ Mitglied')->create(); $schnuppermitglied = Activity::factory()->name('Schnuppermitgliedschaft')->create(); $woelfling = Subactivity::factory()->name('Wölfling')->create(); $rover = Subactivity::factory()->name('Rover')->create(); Member::factory()->defaults() ->has(Membership::factory()->for($mitglied)->for($woelfling)) ->has(Membership::factory()->for($schnuppermitglied)->for($rover)) ->create(); sleep(1); $this->callFilter('member.index', ['activity_ids' => [$mitglied->id, 5, 6], 'subactivity_ids' => [$rover->id, 8, 9]]) ->assertInertiaCount('data.data', 0); } public function testItIgnoresInactiveMemberships(): void { $this->withoutExceptionHandling()->login()->loginNami(); $mitglied = Activity::factory()->name('€ Mitglied')->create(); $woelfling = Subactivity::factory()->name('Wölfling')->create(); Member::factory()->defaults()->has(Membership::factory()->for($mitglied)->for($woelfling)->ended())->create(); sleep(1); $this->callFilter('member.index', ['activity_ids' => [$mitglied->id]]) ->assertInertiaCount('data.data', 0); $this->callFilter('member.index', ['subactivity_ids' => [$woelfling->id]]) ->assertInertiaCount('data.data', 0); } public function testItListensForMembershipDeletion(): void { $this->withoutExceptionHandling()->login()->loginNami(); $mitglied = Activity::factory()->name('€ Mitglied')->create(); $member = Member::factory()->defaults()->has(Membership::factory()->for($mitglied))->create(); $member->memberships->first()->delete(); sleep(1); $this->callFilter('member.index', ['activity_ids' => [$mitglied->id]]) ->assertInertiaCount('data.data', 0); } public function testItFiltersForSearchButNotForPayments(): void { $this->withoutExceptionHandling()->login()->loginNami(); Member::factory()->defaults() ->has(InvoicePosition::factory()->for(Invoice::factory())) ->create(['firstname' => 'firstname']); Member::factory()->defaults()->create(['firstname' => 'firstname']); sleep(1); $this->callFilter('member.index', ['search' => 'firstname', 'ausstand' => true]) ->assertInertiaCount('data.data', 1); } public function testItIgnoresPaidInvoices(): void { $this->withoutExceptionHandling()->login()->loginNami(); Member::factory()->defaults() ->has(InvoicePosition::factory()->for(Invoice::factory()->status(InvoiceStatus::PAID))) ->create(); sleep(1); $this->callFilter('member.index', ['ausstand' => true]) ->assertInertiaCount('data.data', 0); } public function testItIncludesMembers(): void { $this->withoutExceptionHandling()->login()->loginNami(); $member = Member::factory()->defaults()->create(['birthday' => null, 'location' => '']); sleep(1); $this->callFilter('member.index', ['hasBirthday' => true, 'hasFullAddress' => false]) ->assertInertiaCount('data.data', 0); $this->callFilter('member.index', ['hasBirthday' => true, 'hasFullAddress' => false, 'include' => [$member->id]]) ->assertInertiaCount('data.data', 1); } public function testItExcludesMembers(): void { $this->withoutExceptionHandling()->login()->loginNami(); $member = Member::factory()->defaults()->create(['birthday' => null]); sleep(1); $this->callFilter('member.index', ['hasBirthday' => false, 'exclude' => [$member->id]]) ->assertInertiaCount('data.data', 0); } }