Fixed: subscription_id validation
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Philipp Lang 2023-09-07 16:48:51 +02:00
parent 3a96b00307
commit dc832503b4
2 changed files with 19 additions and 1 deletions

View File

@ -41,6 +41,10 @@ class MemberRequest extends FormRequest
'first_subactivity' => 'exclude|required',
] : [],
'subscription_id' => Rule::requiredIf(function () {
if (!$this->input('has_nami')) {
return false;
}
if ('POST' != $this->method()) {
return false;
}

View File

@ -154,7 +154,7 @@ class StoreTest extends TestCase
'zip' => null,
'location' => null,
'joined_at' => null,
]));
]))->assertSessionDoesntHaveErrors();
$this->assertDatabaseHas('members', [
'nationality_id' => null,
'birthday' => null,
@ -165,6 +165,20 @@ class StoreTest extends TestCase
]);
}
public function testItDoesntNeedSubscription(): void
{
$this->login()->loginNami();
$this
->post('/member', $this->attributes([
'has_nami' => false,
'subscription_id' => null,
]))->assertSessionDoesntHaveErrors();
$this->assertDatabaseHas('members', [
'subscription_id' => null,
]);
}
public function testItRequiresFields(): void
{
$this->login()->loginNami();