2022-11-18 15:55:44 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Member;
|
|
|
|
|
2022-11-19 00:09:53 +01:00
|
|
|
use App\Fee;
|
|
|
|
use App\Gender;
|
|
|
|
use App\Group;
|
2022-11-18 15:55:44 +01:00
|
|
|
use App\Member\Member;
|
|
|
|
use App\Member\Membership;
|
2022-11-19 00:09:53 +01:00
|
|
|
use App\Nationality;
|
2022-11-18 22:34:50 +01:00
|
|
|
use App\Payment\Payment;
|
2022-11-19 00:09:53 +01:00
|
|
|
use App\Payment\Subscription;
|
|
|
|
use App\Region;
|
|
|
|
use Carbon\Carbon;
|
2022-11-18 15:55:44 +01:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class ShowTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
2022-11-19 00:09:53 +01:00
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
Carbon::setTestNow(Carbon::parse('2006-01-01 15:00:00'));
|
|
|
|
}
|
|
|
|
|
2022-11-18 15:55:44 +01:00
|
|
|
public function testItShowsSingleMember(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
$member = Member::factory()
|
2022-11-19 00:09:53 +01:00
|
|
|
->defaults()
|
2022-11-18 15:55:44 +01:00
|
|
|
->has(Membership::factory()->in('€ LeiterIn', 5, 'Jungpfadfinder', 88)->state(['created_at' => '2022-11-19 05:00:00']))
|
2022-11-18 22:34:50 +01:00
|
|
|
->has(Payment::factory()->notPaid()->nr('2019')->subscription('Free', 1050))
|
2022-11-19 00:09:53 +01:00
|
|
|
->for(Gender::factory()->name('Herr'))
|
|
|
|
->for(Region::factory()->name('NRW'))
|
|
|
|
->create([
|
|
|
|
'birthday' => '1991-04-20',
|
|
|
|
'address' => 'Itterstr 3',
|
|
|
|
'zip' => '42719',
|
|
|
|
'location' => 'Solingen',
|
|
|
|
'firstname' => 'Max',
|
|
|
|
'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',
|
|
|
|
]);
|
2022-11-18 15:55:44 +01:00
|
|
|
|
|
|
|
$response = $this->get("/member/{$member->id}");
|
|
|
|
|
2022-11-19 00:09:53 +01:00
|
|
|
$this->assertInertiaHas([
|
|
|
|
'birthday_human' => '20.04.1991',
|
|
|
|
'age' => 14,
|
|
|
|
'firstname' => 'Max',
|
|
|
|
'gender_name' => 'Herr',
|
|
|
|
'full_address' => 'Itterstr 3, 42719 Solingen',
|
|
|
|
'region' => ['name' => 'NRW'],
|
|
|
|
'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',
|
|
|
|
], $response, 'data');
|
2022-11-18 15:55:44 +01:00
|
|
|
$this->assertInertiaHas([
|
|
|
|
'activity_name' => '€ LeiterIn',
|
|
|
|
'id' => $member->memberships->first()->id,
|
|
|
|
'human_date' => '19.11.2022',
|
|
|
|
], $response, 'data.memberships.0');
|
2022-11-18 22:34:50 +01:00
|
|
|
$this->assertInertiaHas([
|
|
|
|
'subscription' => [
|
|
|
|
'name' => 'Free',
|
|
|
|
'id' => $member->payments->first()->subscription->id,
|
|
|
|
'amount' => 1050,
|
|
|
|
],
|
|
|
|
'status_name' => 'Nicht bezahlt',
|
|
|
|
'nr' => '2019',
|
|
|
|
], $response, 'data.payments.0');
|
2022-11-18 15:55:44 +01:00
|
|
|
}
|
2022-11-19 00:09:53 +01:00
|
|
|
|
|
|
|
public function testItShowsMinimalSingleMember(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami();
|
|
|
|
$member = Member::factory()
|
|
|
|
->for(Group::factory())
|
|
|
|
->for(Nationality::factory()->name('deutsch'))
|
|
|
|
->for(Subscription::factory()->for(Fee::factory()))
|
|
|
|
->create(['firstname' => 'Max']);
|
|
|
|
|
|
|
|
$response = $this->get("/member/{$member->id}");
|
|
|
|
|
|
|
|
$this->assertInertiaHas([
|
|
|
|
'region' => ['name' => '-- kein --'],
|
|
|
|
'nationality' => ['name' => '-- kein --'],
|
|
|
|
'gender_name' => 'keine Angabe',
|
|
|
|
'nationality' => [
|
|
|
|
'name' => 'deutsch',
|
|
|
|
],
|
|
|
|
], $response, 'data');
|
|
|
|
}
|
2022-11-18 15:55:44 +01:00
|
|
|
}
|