adrema/tests/Feature/Member/ShowTest.php

109 lines
3.6 KiB
PHP
Raw Normal View History

2022-11-18 15:55:44 +01:00
<?php
namespace Tests\Feature\Member;
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;
use App\Nationality;
2022-11-18 22:34:50 +01:00
use App\Payment\Payment;
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;
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()
->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:21:58 +01:00
->for(Gender::factory()->name('Männlich'))
->for(Region::factory()->name('NRW'))
->create([
'birthday' => '1991-04-20',
'address' => 'Itterstr 3',
'zip' => '42719',
'location' => 'Solingen',
'firstname' => 'Max',
2022-11-19 00:21:58 +01:00
'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',
]);
2022-11-18 15:55:44 +01:00
$response = $this->get("/member/{$member->id}");
$this->assertInertiaHas([
'birthday_human' => '20.04.1991',
'age' => 14,
'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',
2022-11-19 00:21:58 +01:00
'fullname' => 'Herr Max Muster',
], $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
}
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()))
2022-11-19 00:21:58 +01:00
->create(['firstname' => 'Max', 'lastname' => 'Muster']);
$response = $this->get("/member/{$member->id}");
$this->assertInertiaHas([
'region' => ['name' => '-- kein --'],
'nationality' => ['name' => '-- kein --'],
2022-11-19 00:21:58 +01:00
'fullname' => 'Max Muster',
'nationality' => [
'name' => 'deutsch',
],
], $response, 'data');
}
2022-11-18 15:55:44 +01:00
}