Fix tests
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
bf067d7352
commit
55b3bc7fe9
|
@ -17,19 +17,19 @@ class MemberShowAction
|
||||||
*/
|
*/
|
||||||
public function handle(Member $member): array
|
public function handle(Member $member): array
|
||||||
{
|
{
|
||||||
|
$member = Member::withPendingPayment()->with([
|
||||||
|
'memberships.activity',
|
||||||
|
'memberships.subactivity',
|
||||||
|
'invoicePositions.invoice',
|
||||||
|
'nationality',
|
||||||
|
'region',
|
||||||
|
'subscription',
|
||||||
|
'courses.course',
|
||||||
|
'bankAccount',
|
||||||
|
])->find($member->id);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'data' => new MemberResource(
|
'data' => new MemberResource($member),
|
||||||
$member
|
|
||||||
->load([
|
|
||||||
'memberships.activity',
|
|
||||||
'memberships.subactivity',
|
|
||||||
'invoicePositions.invoice',
|
|
||||||
'nationality',
|
|
||||||
'region',
|
|
||||||
'subscription',
|
|
||||||
'courses.course'
|
|
||||||
])
|
|
||||||
),
|
|
||||||
'meta' => MemberResource::meta(),
|
'meta' => MemberResource::meta(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ class MemberResource extends JsonResource
|
||||||
return [
|
return [
|
||||||
'filterActivities' => Activity::where('is_filterable', true)->get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
'filterActivities' => Activity::where('is_filterable', true)->get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
||||||
'filterSubactivities' => Subactivity::where('is_filterable', true)->get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
'filterSubactivities' => Subactivity::where('is_filterable', true)->get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
||||||
'formActivities' => $activities->pluck('name', 'id'),
|
'formActivities' => $activities->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
||||||
'formSubactivities' => $activities->map(function (Activity $activity) {
|
'formSubactivities' => $activities->map(function (Activity $activity) {
|
||||||
return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id];
|
return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id];
|
||||||
})->pluck('subactivities', 'id'),
|
})->pluck('subactivities', 'id'),
|
||||||
|
@ -148,11 +148,11 @@ class MemberResource extends JsonResource
|
||||||
})->pluck('subactivities', 'id'),
|
})->pluck('subactivities', 'id'),
|
||||||
'groups' => NestedGroup::cacheForSelect(),
|
'groups' => NestedGroup::cacheForSelect(),
|
||||||
'filter' => FilterScope::fromRequest(request()->input('filter', '')),
|
'filter' => FilterScope::fromRequest(request()->input('filter', '')),
|
||||||
'courses' => Course::pluck('name', 'id'),
|
'courses' => Course::get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
||||||
'regions' => Region::forSelect(),
|
'regions' => Region::get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
||||||
'subscriptions' => Subscription::pluck('name', 'id'),
|
'subscriptions' => Subscription::get()->map(fn($a) => ['id' => $a->id, 'name' => $a->name]),
|
||||||
'countries' => Country::pluck('name', 'id'),
|
'countries' => Country::get()->map(fn($c) => ['id' => $c->id, 'name' => $c->name]),
|
||||||
'genders' => Gender::pluck('name', 'id'),
|
'genders' => Gender::get()->map(fn($c) => ['id' => $c->id, 'name' => $c->name]),
|
||||||
'billKinds' => BillKind::forSelect(),
|
'billKinds' => BillKind::forSelect(),
|
||||||
'nationalities' => Nationality::pluck('name', 'id'),
|
'nationalities' => Nationality::pluck('name', 'id'),
|
||||||
'members' => Member::ordered()->get()->map(fn($member) => ['id' => $member->id, 'name' => $member->fullname]),
|
'members' => Member::ordered()->get()->map(fn($member) => ['id' => $member->id, 'name' => $member->fullname]),
|
||||||
|
|
|
@ -68,11 +68,6 @@ parameters:
|
||||||
count: 1
|
count: 1
|
||||||
path: app/Member/MemberRequest.php
|
path: app/Member/MemberRequest.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method App\\\\Membership\\\\MembershipResource\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: app/Membership/MembershipResource.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Method App\\\\Payment\\\\SubscriptionResource\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
|
message: "#^Method App\\\\Payment\\\\SubscriptionResource\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
|
|
@ -33,11 +33,6 @@ class CreateTest extends TestCase
|
||||||
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'meta.billKinds.0');
|
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'meta.billKinds.0');
|
||||||
|
|
||||||
$this->assertInertiaHas([
|
$this->assertInertiaHas([
|
||||||
'efz' => null,
|
|
||||||
'ps_at' => null,
|
|
||||||
'more_ps_at' => null,
|
|
||||||
'without_education_at' => null,
|
|
||||||
'without_efz_at' => null,
|
|
||||||
'address' => '',
|
'address' => '',
|
||||||
], $response, 'meta.default');
|
], $response, 'meta.default');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,174 +2,253 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Member;
|
namespace Tests\Feature\Member;
|
||||||
|
|
||||||
|
use App\Activity;
|
||||||
|
use App\Confession;
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use App\Course\Models\Course;
|
use App\Course\Models\Course;
|
||||||
use App\Course\Models\CourseMember;
|
use App\Course\Models\CourseMember;
|
||||||
use App\Gender;
|
use App\Gender;
|
||||||
use App\Group;
|
use App\Group;
|
||||||
|
use App\Invoice\BillKind;
|
||||||
use App\Invoice\Models\Invoice;
|
use App\Invoice\Models\Invoice;
|
||||||
use App\Invoice\Models\InvoicePosition;
|
use App\Invoice\Models\InvoicePosition;
|
||||||
use App\Member\Data\MembershipData;
|
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
|
use App\Member\MemberResource;
|
||||||
use App\Member\Membership;
|
use App\Member\Membership;
|
||||||
use App\Nationality;
|
use App\Nationality;
|
||||||
use App\Payment\Subscription;
|
use App\Payment\Subscription;
|
||||||
use App\Region;
|
use App\Region;
|
||||||
|
use App\Subactivity;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
uses(DatabaseTransactions::class);
|
uses(DatabaseTransactions::class);
|
||||||
covers(MembershipData::class);
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
Country::factory()->create(['name' => 'Deutschland']);
|
Country::factory()->create(['name' => 'Deutschland']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('testItShowsSingleMember', function () {
|
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'));
|
Carbon::setTestNow(Carbon::parse('2006-01-01 15:00:00'));
|
||||||
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$member = Member::factory()
|
$member = Member::factory()
|
||||||
->defaults()
|
->defaults()
|
||||||
->for(Group::factory()->name('Stamm Beispiel'))
|
->for(Group::factory()->name('Stamm Beispiel'))
|
||||||
->has(Membership::factory()->promise(now())->in('€ LeiterIn', 5, 'Jungpfadfinder', 88)->from('2022-11-19'))
|
->has(Membership::factory()->promise(now())->in('€ LeiterIn', 5, 'Jungpfadfinder', 88)->from('2005-11-19'))
|
||||||
->has(InvoicePosition::factory()->for(Invoice::factory())->price(1050)->description('uu'))
|
->create();
|
||||||
->for(Gender::factory()->male())
|
|
||||||
->for(Region::factory()->name('NRW'))
|
|
||||||
->postBillKind()
|
|
||||||
->inNami(123)
|
|
||||||
->for(Subscription::factory()->name('Sub')->forFee())
|
|
||||||
->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([
|
|
||||||
'birthday' => '1991-04-20',
|
|
||||||
'address' => 'Itterstr 3',
|
|
||||||
'zip' => '42719',
|
|
||||||
'location' => 'Solingen',
|
|
||||||
'firstname' => 'Max',
|
|
||||||
'lastname' => 'Muster',
|
|
||||||
'other_country' => 'other',
|
|
||||||
'main_phone' => '+49 212 1266775',
|
|
||||||
'mobile_phone' => '+49 212 1266776',
|
|
||||||
'work_phone' => '+49 212 1266777',
|
|
||||||
'children_phone' => '+49 212 1266778',
|
|
||||||
'email' => 'a@b.de',
|
|
||||||
'email_parents' => 'b@c.de',
|
|
||||||
'fax' => '+49 212 1255674',
|
|
||||||
'efz' => '2022-09-20',
|
|
||||||
'ps_at' => '2022-04-20',
|
|
||||||
'more_ps_at' => '2022-06-02',
|
|
||||||
'recertified_at' => '2022-06-13',
|
|
||||||
'without_education_at' => '2022-06-03',
|
|
||||||
'without_efz_at' => '2022-06-04',
|
|
||||||
'has_vk' => true,
|
|
||||||
'has_svk' => true,
|
|
||||||
'multiply_pv' => true,
|
|
||||||
'multiply_more_pv' => true,
|
|
||||||
'send_newspaper' => true,
|
|
||||||
'joined_at' => '2022-06-11',
|
|
||||||
'mitgliedsnr' => 998,
|
|
||||||
'lon' => 19.05,
|
|
||||||
'lat' => 14.053,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = $this->get("/member/{$member->id}");
|
$this->get("/member/{$member->id}")
|
||||||
|
->assertInertiaPath('data.age_group_icon', 'jungpfadfinder')
|
||||||
$this->assertInertiaHas([
|
->assertInertiaPath('data.is_leader', true)
|
||||||
'birthday_human' => '20.04.1991',
|
->assertInertiaPath('data.memberships.0.id', $member->memberships->first()->id)
|
||||||
'age' => 14,
|
->assertInertiaPath('data.memberships.0.from.human', '19.11.2005')
|
||||||
'group_name' => 'Stamm Beispiel',
|
->assertInertiaPath('data.memberships.0.from.raw', '2005-11-19')
|
||||||
'full_address' => 'Itterstr 3, 42719 Solingen',
|
->assertInertiaPath('data.memberships.0.promised_at.human', now()->format('d.m.Y'))
|
||||||
'region' => ['name' => 'NRW'],
|
->assertInertiaPath('data.memberships.0.promised_at.raw', now()->format('Y-m-d'))
|
||||||
'other_country' => 'other',
|
->assertInertiaPath('data.memberships.0.activity.name', '€ LeiterIn')
|
||||||
'main_phone' => '+49 212 1266775',
|
->assertInertiaPath('data.memberships.0.activity.id', $member->memberships->first()->activity->id)
|
||||||
'mobile_phone' => '+49 212 1266776',
|
->assertInertiaPath('data.memberships.0.subactivity.name', 'Jungpfadfinder')
|
||||||
'work_phone' => '+49 212 1266777',
|
->assertInertiaPath('data.memberships.0.subactivity.id', $member->memberships->first()->subactivity->id);
|
||||||
'children_phone' => '+49 212 1266778',
|
|
||||||
'email' => 'a@b.de',
|
|
||||||
'email_parents' => 'b@c.de',
|
|
||||||
'fax' => '+49 212 1255674',
|
|
||||||
'fullname' => 'Herr Max Muster',
|
|
||||||
'efz_human' => '20.09.2022',
|
|
||||||
'ps_at_human' => '20.04.2022',
|
|
||||||
'more_ps_at_human' => '02.06.2022',
|
|
||||||
'without_education_at_human' => '03.06.2022',
|
|
||||||
'without_efz_at_human' => '04.06.2022',
|
|
||||||
'recertified_at_human' => '13.06.2022',
|
|
||||||
'has_vk' => true,
|
|
||||||
'has_svk' => true,
|
|
||||||
'multiply_pv' => true,
|
|
||||||
'multiply_more_pv' => true,
|
|
||||||
'has_nami' => true,
|
|
||||||
'nami_id' => 123,
|
|
||||||
'send_newspaper' => true,
|
|
||||||
'joined_at_human' => '11.06.2022',
|
|
||||||
'bill_kind_name' => 'Post',
|
|
||||||
'mitgliedsnr' => 998,
|
|
||||||
'lon' => 19.05,
|
|
||||||
'lat' => 14.053,
|
|
||||||
'subscription' => [
|
|
||||||
'name' => 'Sub',
|
|
||||||
],
|
|
||||||
], $response, 'data');
|
|
||||||
$this->assertInertiaHas([
|
|
||||||
'id' => $member->memberships->first()->id,
|
|
||||||
'from' => ['human' => '19.11.2022', 'raw' => '2022-11-19'],
|
|
||||||
'promised_at' => ['human' => now()->format('d.m.Y'), 'raw' => now()->format('Y-m-d')],
|
|
||||||
'activity' => [
|
|
||||||
'name' => '€ LeiterIn',
|
|
||||||
'id' => $member->memberships->first()->activity->id,
|
|
||||||
],
|
|
||||||
'subactivity' => [
|
|
||||||
'name' => 'Jungpfadfinder',
|
|
||||||
'id' => $member->memberships->first()->subactivity->id,
|
|
||||||
]
|
|
||||||
], $response, 'data.memberships.0');
|
|
||||||
|
|
||||||
$this->assertInertiaHas([
|
|
||||||
'organizer' => 'DPSG',
|
|
||||||
'event_name' => 'Wochenende',
|
|
||||||
'completed_at_human' => '03.03.2022',
|
|
||||||
'course' => [
|
|
||||||
'name' => ' Baustein 2e - Gewalt gegen Kinder und Jugendliche: Vertiefung, Prävention ',
|
|
||||||
'short_name' => '2e',
|
|
||||||
],
|
|
||||||
], $response, 'data.courses.0');
|
|
||||||
$this->assertInertiaHas([
|
|
||||||
'description' => 'uu',
|
|
||||||
'price_human' => '10,50 €',
|
|
||||||
'invoice' => [
|
|
||||||
'status' => 'Neu',
|
|
||||||
]
|
|
||||||
], $response, 'data.invoicePositions.0');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('testItShowsMinimalSingleMember', function () {
|
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();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$member = Member::factory()
|
$member = Member::factory()
|
||||||
->for(Group::factory())
|
->for(Group::factory())
|
||||||
->for(Nationality::factory()->name('deutsch'))
|
->for(Nationality::factory()->name('deutsch'))
|
||||||
->for(Subscription::factory()->forFee())
|
->for(Subscription::factory()->forFee())
|
||||||
->create(['firstname' => 'Max', 'lastname' => 'Muster', 'has_vk' => false, 'has_svk' => false]);
|
->create($attributes);
|
||||||
|
|
||||||
$response = $this->get("/member/{$member->id}");
|
$this->get("/member/{$member->id}")
|
||||||
|
->assertInertiaPath('data.id', $member->id)
|
||||||
$this->assertInertiaHas([
|
->assertInertiaPathArray($expect);
|
||||||
'region' => ['name' => '-- kein --'],
|
})->with([
|
||||||
'fullname' => 'Max Muster',
|
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]],
|
||||||
'nationality' => [
|
fn() => [['confession_id' => Confession::factory()->create(['name' => 'UUU'])->id], ['data.confession_id' => Confession::firstWhere('name', 'UUU')->id]],
|
||||||
'name' => 'deutsch',
|
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]],
|
||||||
'efz_human' => null,
|
fn() => [['bill_kind' => BillKind::EMAIL->value], ['data.bill_kind_name' => 'E-Mail', 'data.bill_kind' => 'E-Mail']],
|
||||||
'ps_at_human' => null,
|
fn() => [['subscription_id' => Subscription::factory()->name('Sub')->forFee()->create()], ['data.subscription.name' => 'Sub', 'data.subscription_id' => Subscription::first()->id]],
|
||||||
'more_ps_at_human' => null,
|
fn() => [['country_id' => Country::factory()->create(['name' => 'Sub'])->id], ['data.country_id' => Country::firstWhere('name', 'Sub')->id]],
|
||||||
'without_education_at_human' => null,
|
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]],
|
||||||
'without_efz_at_human' => null,
|
[['firstname' => 'Max', 'lastname' => 'Muster', 'gender_id' => null], ['data.fullname' => 'Max Muster']],
|
||||||
'has_vk' => false,
|
[['other_country' => 'other', 'further_address' => 'other', 'letter_address' => 'A'], ['data.other_country' => 'other', 'data.further_address' => 'other', 'data.letter_address' => 'A']],
|
||||||
'has_svk' => false,
|
[['gender_id' => null], ['data.gender_name' => 'keine Angabe']],
|
||||||
'multiply_pv' => false,
|
[['salutation' => 'Dr'], ['data.salutation' => 'Dr']],
|
||||||
'multiply_more_pv' => false,
|
[['comment' => 'Com'], ['data.comment' => 'Com']],
|
||||||
], $response, 'data');
|
[['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) {
|
it('testItShowsIfMembershipIsActive', function (Carbon $from, ?Carbon $to, bool $isActive) {
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
|
|
|
@ -119,12 +119,24 @@ class TestCase extends BaseTestCase
|
||||||
/** @var TestResponse */
|
/** @var TestResponse */
|
||||||
$response = $this;
|
$response = $this;
|
||||||
$props = data_get($response->viewData('page'), 'props');
|
$props = data_get($response->viewData('page'), 'props');
|
||||||
|
Assert::assertTrue(Arr::has($props, $path), 'Failed that key ' . $path . ' is in Response.');
|
||||||
Assert::assertNotNull($props);
|
Assert::assertNotNull($props);
|
||||||
$json = new AssertableJsonString($props);
|
$json = new AssertableJsonString($props);
|
||||||
$json->assertPath($path, $value);
|
$json->assertPath($path, $value);
|
||||||
return $this;
|
return $this;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
TestResponse::macro('assertInertiaPathArray', function ($arr) {
|
||||||
|
/** @var TestResponse */
|
||||||
|
$response = $this;
|
||||||
|
|
||||||
|
foreach ($arr as $key => $value) {
|
||||||
|
$response->assertInertiaPath($key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
});
|
||||||
|
|
||||||
TestResponse::macro('assertInertiaCount', function ($path, $count) {
|
TestResponse::macro('assertInertiaCount', function ($path, $count) {
|
||||||
/** @var TestResponse */
|
/** @var TestResponse */
|
||||||
$response = $this;
|
$response = $this;
|
||||||
|
|
Loading…
Reference in New Issue