2021-07-17 15:58:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Member;
|
|
|
|
|
2022-03-20 16:33:56 +01:00
|
|
|
use App\Activity;
|
2023-02-25 19:49:53 +01:00
|
|
|
use App\Group;
|
2021-07-17 15:58:38 +02:00
|
|
|
use App\Member\Member;
|
2022-03-20 16:33:56 +01:00
|
|
|
use App\Member\Membership;
|
2022-11-18 22:41:40 +01:00
|
|
|
use App\Payment\Payment;
|
2022-03-20 16:33:56 +01:00
|
|
|
use App\Subactivity;
|
2022-02-12 01:08:56 +01:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2022-12-13 23:11:32 +01:00
|
|
|
use Tests\RequestFactories\Child;
|
2021-07-17 15:58:38 +02:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class IndexTest extends TestCase
|
|
|
|
{
|
2022-02-12 01:08:56 +01:00
|
|
|
use DatabaseTransactions;
|
2021-07-17 15:58:38 +02:00
|
|
|
|
|
|
|
public function testItGetsMembers(): void
|
|
|
|
{
|
2022-11-16 22:28:42 +01:00
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2023-02-25 19:49:53 +01:00
|
|
|
$group = Group::factory()->create();
|
|
|
|
Member::factory()->defaults()->for($group)->create([
|
2022-11-23 23:24:32 +01:00
|
|
|
'firstname' => '::firstname::',
|
|
|
|
'address' => 'Kölner Str 3',
|
|
|
|
'zip' => 33333,
|
|
|
|
'location' => 'Hilden',
|
|
|
|
]);
|
2021-07-17 15:58:38 +02:00
|
|
|
|
2022-02-12 00:41:52 +01:00
|
|
|
$response = $this->get('/member');
|
|
|
|
|
2022-02-12 15:33:16 +01:00
|
|
|
$this->assertComponent('member/VIndex', $response);
|
2022-02-12 00:41:52 +01:00
|
|
|
$this->assertInertiaHas('::firstname::', $response, 'data.data.0.firstname');
|
2022-11-23 23:24:32 +01:00
|
|
|
$this->assertInertiaHas('Kölner Str 3, 33333 Hilden', $response, 'data.data.0.full_address');
|
2023-02-25 19:49:53 +01:00
|
|
|
$this->assertInertiaHas($group->id, $response, 'data.data.0.group_id');
|
2021-07-17 15:58:38 +02:00
|
|
|
}
|
2022-03-20 16:33:56 +01:00
|
|
|
|
2023-03-06 00:26:17 +01:00
|
|
|
public function testFieldsCanBeNull(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
$group = Group::factory()->create();
|
|
|
|
Member::factory()->defaults()->for($group)->create([
|
|
|
|
'birthday' => null,
|
|
|
|
'address' => null,
|
|
|
|
'zip' => null,
|
|
|
|
'location' => null,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$response = $this->get('/member');
|
|
|
|
|
|
|
|
$this->assertInertiaHas(null, $response, 'data.data.0.birthday');
|
|
|
|
$this->assertInertiaHas(null, $response, 'data.data.0.address');
|
|
|
|
$this->assertInertiaHas(null, $response, 'data.data.0.zip');
|
|
|
|
$this->assertInertiaHas(null, $response, 'data.data.0.location');
|
|
|
|
}
|
|
|
|
|
2022-03-20 16:33:56 +01:00
|
|
|
public function testItShowsEfzForEfzMembership(): void
|
|
|
|
{
|
2022-11-16 22:28:42 +01:00
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2022-03-20 16:33:56 +01:00
|
|
|
$member = Member::factory()
|
|
|
|
->defaults()
|
2022-11-16 22:28:42 +01:00
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 455, 'Pfadfinder', 15))
|
2022-03-20 16:33:56 +01:00
|
|
|
->create(['lastname' => 'A']);
|
|
|
|
Member::factory()
|
|
|
|
->defaults()
|
2022-11-16 22:28:42 +01:00
|
|
|
->has(Membership::factory()->in('€ Mitglied', 456, 'Pfadfinder', 16))
|
2022-03-20 16:33:56 +01:00
|
|
|
->create(['lastname' => 'B']);
|
|
|
|
Member::factory()
|
|
|
|
->defaults()
|
|
|
|
->create(['lastname' => 'C']);
|
|
|
|
|
|
|
|
$response = $this->get('/member');
|
|
|
|
|
|
|
|
$this->assertInertiaHas(url("/member/{$member->id}/efz"), $response, 'data.data.0.efz_link');
|
|
|
|
$this->assertInertiaHas(null, $response, 'data.data.1.efz_link');
|
|
|
|
$this->assertInertiaHas(null, $response, 'data.data.2.efz_link');
|
2022-09-06 01:25:04 +02:00
|
|
|
$this->assertInertiaHas(true, $response, 'data.data.0.is_leader');
|
|
|
|
$this->assertInertiaHas(false, $response, 'data.data.1.is_leader');
|
|
|
|
$this->assertInertiaHas(false, $response, 'data.data.2.is_leader');
|
2022-03-20 16:33:56 +01:00
|
|
|
}
|
2022-11-16 16:30:23 +01:00
|
|
|
|
|
|
|
public function testItShowsAgeGroupIcon(): void
|
|
|
|
{
|
2022-11-16 22:28:42 +01:00
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2022-11-16 16:30:23 +01:00
|
|
|
$member = Member::factory()
|
|
|
|
->defaults()
|
2022-11-16 22:28:42 +01:00
|
|
|
->has(Membership::factory()->in('€ Mitglied', 123, 'Wölfling', 12))
|
2022-11-16 16:30:23 +01:00
|
|
|
->create();
|
|
|
|
|
|
|
|
$response = $this->get('/member');
|
|
|
|
|
|
|
|
$this->assertInertiaHas('woelfling', $response, 'data.data.0.age_group_icon');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItShowsActivitiesAndSubactivities(): void
|
|
|
|
{
|
2022-11-16 22:28:42 +01:00
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
$activity = Activity::factory()->hasAttached(Subactivity::factory()->name('Biber'))->name('€ Mitglied')->create();
|
2022-11-16 16:30:23 +01:00
|
|
|
$subactivity = $activity->subactivities->first();
|
|
|
|
|
|
|
|
$response = $this->get('/member');
|
|
|
|
|
2022-11-16 22:28:42 +01:00
|
|
|
$this->assertInertiaHas('Biber', $response, "subactivities.{$activity->id}.{$subactivity->id}");
|
|
|
|
$this->assertInertiaHas('Biber', $response, "filterSubactivities.{$subactivity->id}");
|
|
|
|
$this->assertInertiaHas('€ Mitglied', $response, "activities.{$activity->id}");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItShowsActivityAndSubactivityNamesOfMember(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2023-02-25 19:49:53 +01:00
|
|
|
$group = Group::factory()->create();
|
2022-11-16 22:28:42 +01:00
|
|
|
$member = Member::factory()
|
|
|
|
->defaults()
|
2023-02-27 22:00:27 +01:00
|
|
|
->has(Membership::factory()->for($group)->in('€ Mitglied', 122, 'Wölfling', 234)->from('2022-11-02'))
|
2022-11-16 22:28:42 +01:00
|
|
|
->create();
|
|
|
|
|
|
|
|
$response = $this->get('/member');
|
|
|
|
|
|
|
|
$this->assertInertiaHas([
|
2022-11-16 23:52:38 +01:00
|
|
|
'activity_id' => $member->memberships->first()->activity_id,
|
|
|
|
'subactivity_id' => $member->memberships->first()->subactivity_id,
|
2022-11-16 22:28:42 +01:00
|
|
|
'activity_name' => '€ Mitglied',
|
|
|
|
'subactivity_name' => 'Wölfling',
|
|
|
|
'human_date' => '02.11.2022',
|
2023-02-25 19:49:53 +01:00
|
|
|
'group_id' => $group->id,
|
2022-11-16 22:28:42 +01:00
|
|
|
'id' => $member->memberships->first()->id,
|
|
|
|
], $response, 'data.data.0.memberships.0');
|
2022-11-16 16:30:23 +01:00
|
|
|
}
|
2022-11-18 22:41:40 +01:00
|
|
|
|
2023-03-22 23:43:09 +01:00
|
|
|
public function testItDoesntShowEndedMemberships(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
$group = Group::factory()->create();
|
|
|
|
$member = Member::factory()
|
|
|
|
->defaults()
|
|
|
|
->has(Membership::factory()->for($group)->in('€ Mitglied', 122, 'Wölfling', 234)->ended())
|
|
|
|
->create();
|
|
|
|
|
|
|
|
$response = $this->get('/member');
|
|
|
|
|
|
|
|
$this->assertCount(0, $this->inertia($response, 'data.data.0.memberships'));
|
|
|
|
}
|
|
|
|
|
2022-11-18 22:41:40 +01:00
|
|
|
public function testItReturnsPayments(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
$member = Member::factory()
|
2022-12-13 23:11:32 +01:00
|
|
|
->has(Payment::factory()->notPaid()->nr('2019')->subscription('Free', [
|
|
|
|
new Child('a', 1000),
|
|
|
|
new Child('b', 50),
|
|
|
|
]))
|
2022-11-18 22:41:40 +01:00
|
|
|
->defaults()->create();
|
|
|
|
|
|
|
|
$response = $this->get('/member');
|
|
|
|
|
|
|
|
$this->assertInertiaHas([
|
|
|
|
'subscription' => [
|
|
|
|
'name' => 'Free',
|
|
|
|
'id' => $member->payments->first()->subscription->id,
|
|
|
|
'amount' => 1050,
|
|
|
|
],
|
|
|
|
'subscription_id' => $member->payments->first()->subscription->id,
|
|
|
|
'status_name' => 'Nicht bezahlt',
|
|
|
|
'nr' => '2019',
|
|
|
|
], $response, 'data.data.0.payments.0');
|
2022-11-22 00:37:34 +01:00
|
|
|
$this->assertInertiaHas([
|
|
|
|
'id' => $member->subscription->id,
|
|
|
|
'name' => $member->subscription->name,
|
|
|
|
], $response, 'data.data.0.subscription');
|
2022-11-18 22:41:40 +01:00
|
|
|
}
|
2022-12-06 23:11:57 +01:00
|
|
|
|
|
|
|
public function testItCanFilterForBillKinds(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
2023-02-23 01:30:31 +01:00
|
|
|
Member::factory()->defaults()->emailBillKind()->create();
|
|
|
|
Member::factory()->defaults()->postBillKind()->create();
|
2023-03-14 23:27:15 +01:00
|
|
|
Member::factory()->defaults()->postBillKind()->create();
|
2022-12-06 23:11:57 +01:00
|
|
|
|
2023-03-14 23:27:15 +01:00
|
|
|
$emailResponse = $this->callFilter('member.index', ['bill_kind' => 'E-Mail']);
|
|
|
|
$postResponse = $this->callFilter('member.index', ['bill_kind' => 'Post']);
|
2022-12-06 23:11:57 +01:00
|
|
|
|
|
|
|
$this->assertCount(1, $this->inertia($emailResponse, 'data.data'));
|
2023-03-14 23:27:15 +01:00
|
|
|
$this->assertCount(2, $this->inertia($postResponse, 'data.data'));
|
|
|
|
$this->assertInertiaHas('E-Mail', $emailResponse, 'data.meta.filter.bill_kind');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItFiltersForAusstand(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
Member::factory()
|
|
|
|
->has(Payment::factory()->notPaid()->subscription('Free', [new Child('b', 50)]))
|
|
|
|
->defaults()->create();
|
|
|
|
Member::factory()->defaults()->create();
|
|
|
|
Member::factory()->defaults()->create();
|
|
|
|
|
|
|
|
$defaultResponse = $this->callFilter('member.index', []);
|
|
|
|
$ausstandResponse = $this->callFilter('member.index', ['ausstand' => true]);
|
|
|
|
|
|
|
|
$this->assertCount(3, $this->inertia($defaultResponse, 'data.data'));
|
|
|
|
$this->assertCount(1, $this->inertia($ausstandResponse, 'data.data'));
|
|
|
|
$this->assertInertiaHas(true, $ausstandResponse, 'data.meta.filter.ausstand');
|
|
|
|
$this->assertInertiaHas(false, $defaultResponse, 'data.meta.filter.ausstand');
|
2022-12-06 23:11:57 +01:00
|
|
|
}
|
2023-02-23 01:30:31 +01:00
|
|
|
|
2023-03-15 11:16:52 +01:00
|
|
|
public function testItHandlesFullTextSearch(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
|
2023-03-22 23:37:36 +01:00
|
|
|
$searchResponse = $this->callFilter('member.index', ['search' => 'Maxö']);
|
2023-03-15 11:16:52 +01:00
|
|
|
|
2023-03-22 23:37:36 +01:00
|
|
|
$this->assertInertiaHas('Maxö', $searchResponse, 'data.meta.filter.search');
|
2023-03-15 11:16:52 +01:00
|
|
|
}
|
|
|
|
|
2023-02-25 19:49:53 +01:00
|
|
|
public function testItLoadsGroups(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
Group::factory()->name('UUI')->create();
|
|
|
|
|
|
|
|
$response = $this->get('/member');
|
|
|
|
|
|
|
|
$this->assertInertiaHas('UUI', $response, 'data.meta.groups.1.name');
|
|
|
|
}
|
2021-07-17 15:58:38 +02:00
|
|
|
}
|