Add gender as a nami field
This commit is contained in:
parent
700d69d1a2
commit
86aaf55d21
|
@ -18,6 +18,7 @@ enum NamiType: string
|
||||||
case ADDRESS = 'Adresse';
|
case ADDRESS = 'Adresse';
|
||||||
case ZIP = 'PLZ';
|
case ZIP = 'PLZ';
|
||||||
case LOCATION = 'Ort';
|
case LOCATION = 'Ort';
|
||||||
|
case GENDER = 'Geschlecht';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, array{name: string, id: string}>
|
* @return array<int, array{name: string, id: string}>
|
||||||
|
@ -42,6 +43,7 @@ enum NamiType: string
|
||||||
static::ZIP => $member->zip,
|
static::ZIP => $member->zip,
|
||||||
static::LOCATION => $member->location,
|
static::LOCATION => $member->location,
|
||||||
static::NICKNAME => $member->nickname,
|
static::NICKNAME => $member->nickname,
|
||||||
|
static::GENDER => $member->gender?->name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
namespace Database\Factories\Member;
|
namespace Database\Factories\Member;
|
||||||
|
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use App\Fee;
|
use App\Gender;
|
||||||
use App\Group;
|
use App\Group;
|
||||||
use App\Invoice\BillKind;
|
use App\Invoice\BillKind;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
|
@ -68,6 +68,16 @@ class MemberFactory extends Factory
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function male(): self
|
||||||
|
{
|
||||||
|
return $this->for(Gender::factory()->male());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function female(): self
|
||||||
|
{
|
||||||
|
return $this->for(Gender::factory()->female());
|
||||||
|
}
|
||||||
|
|
||||||
public function emailBillKind(): self
|
public function emailBillKind(): self
|
||||||
{
|
{
|
||||||
return $this->state([
|
return $this->state([
|
||||||
|
|
|
@ -10,6 +10,7 @@ use App\Group;
|
||||||
use App\Group\Enums\Level;
|
use App\Group\Enums\Level;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Database\Factories\Member\MemberFactory;
|
||||||
use Generator;
|
use Generator;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
@ -480,6 +481,19 @@ class FormRegisterActionTest extends FormTestCase
|
||||||
NamiType::BIRTHDAY,
|
NamiType::BIRTHDAY,
|
||||||
'2023-06-06'
|
'2023-06-06'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
yield [
|
||||||
|
[],
|
||||||
|
NamiType::GENDER,
|
||||||
|
'Männlich',
|
||||||
|
fn (MemberFactory $factory) => $factory->male(),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield [
|
||||||
|
['gender_id' => null],
|
||||||
|
NamiType::GENDER,
|
||||||
|
'',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -487,10 +501,10 @@ class FormRegisterActionTest extends FormTestCase
|
||||||
* @param array<string, string> $memberAttributes
|
* @param array<string, string> $memberAttributes
|
||||||
* @param mixed $participantValue
|
* @param mixed $participantValue
|
||||||
*/
|
*/
|
||||||
public function testItSynchsMemberAttributes(array $memberAttributes, NamiType $type, mixed $participantValue): void
|
public function testItSynchsMemberAttributes(array $memberAttributes, NamiType $type, mixed $participantValue, ?callable $factory = null): void
|
||||||
{
|
{
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$this->createMember(['mitgliedsnr' => '5505', ...$memberAttributes]);
|
$this->createMember(['mitgliedsnr' => '5505', ...$memberAttributes], $factory);
|
||||||
$form = Form::factory()->fields([
|
$form = Form::factory()->fields([
|
||||||
$this->namiField('members'),
|
$this->namiField('members'),
|
||||||
$this->textField('other')->required(true)->namiType($type),
|
$this->textField('other')->required(true)->namiType($type),
|
||||||
|
@ -666,9 +680,10 @@ class FormRegisterActionTest extends FormTestCase
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $attributes
|
* @param array<string, mixed> $attributes
|
||||||
*/
|
*/
|
||||||
protected function createMember(array $attributes): Member
|
protected function createMember(array $attributes, ?callable $factoryCallback = null): Member
|
||||||
{
|
{
|
||||||
return Member::factory()->defaults()->create($attributes);
|
return call_user_func($factoryCallback ?: fn ($factory) => $factory, Member::factory()->defaults())
|
||||||
|
->create($attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue