Fix UpdateTest
This commit is contained in:
parent
aac47190e5
commit
12dd1f7f64
|
@ -4,6 +4,7 @@ namespace App\Member;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Setting\NamiSettings;
|
use App\Setting\NamiSettings;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
|
@ -34,14 +35,14 @@ class MemberController extends Controller
|
||||||
return redirect()->route('member.index');
|
return redirect()->route('member.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Member $member, MemberRequest $request): RedirectResponse
|
public function update(Member $member, MemberRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$request->persistUpdate($member);
|
$request->persistUpdate($member);
|
||||||
} catch (ConflictException $e) {
|
} catch (ConflictException $e) {
|
||||||
return redirect()->route('member.edit', ['member' => $member, 'conflict' => '1']);
|
return response()->json([], 409);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->route('member.index');
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,8 @@ class UpdateTest extends TestCase
|
||||||
$this->fakeRequest();
|
$this->fakeRequest();
|
||||||
NamiPutMemberAction::allowToRun();
|
NamiPutMemberAction::allowToRun();
|
||||||
|
|
||||||
$response = $this
|
$this->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true]));
|
||||||
->from("/member/{$member->id}")
|
|
||||||
->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true]));
|
|
||||||
|
|
||||||
$response->assertRedirect('/member');
|
|
||||||
NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs(
|
NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs(
|
||||||
fn (Member $memberParam, ?Activity $activityParam, ?Subactivity $subactivityParam) => $memberParam->is($member)
|
fn (Member $memberParam, ?Activity $activityParam, ?Subactivity $subactivityParam) => $memberParam->is($member)
|
||||||
&& null === $activityParam
|
&& null === $activityParam
|
||||||
|
@ -49,11 +46,8 @@ class UpdateTest extends TestCase
|
||||||
$member->update(['version' => 43]);
|
$member->update(['version' => 43]);
|
||||||
$this->fakeRequest();
|
$this->fakeRequest();
|
||||||
|
|
||||||
$response = $this
|
$this->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::']))
|
||||||
->from("/member/{$member->id}")
|
->assertStatus(409);
|
||||||
->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::']));
|
|
||||||
|
|
||||||
$response->assertRedirect("/member/{$member->id}/edit?conflict=1");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItUpdatesPhoneNumber(): void
|
public function testItUpdatesPhoneNumber(): void
|
||||||
|
@ -99,11 +93,9 @@ class UpdateTest extends TestCase
|
||||||
$member = $this->member(['nami_id' => null]);
|
$member = $this->member(['nami_id' => null]);
|
||||||
$this->fakeRequest();
|
$this->fakeRequest();
|
||||||
|
|
||||||
$response = $this
|
$this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
|
||||||
->from("/member/{$member->id}")
|
'other_country' => 'englisch',
|
||||||
->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
|
]));
|
||||||
'other_country' => 'englisch',
|
|
||||||
]));
|
|
||||||
|
|
||||||
$this->assertEquals('englisch', $member->fresh()->other_country);
|
$this->assertEquals('englisch', $member->fresh()->other_country);
|
||||||
}
|
}
|
||||||
|
@ -158,22 +150,20 @@ class UpdateTest extends TestCase
|
||||||
$member = $this->member(['nami_id' => null]);
|
$member = $this->member(['nami_id' => null]);
|
||||||
$this->fakeRequest();
|
$this->fakeRequest();
|
||||||
|
|
||||||
$response = $this
|
$this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
|
||||||
->from("/member/{$member->id}")
|
'ps_at' => '2021-02-01',
|
||||||
->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
|
'more_ps_at' => '2021-02-02',
|
||||||
'ps_at' => '2021-02-01',
|
'has_svk' => true,
|
||||||
'more_ps_at' => '2021-02-02',
|
'has_vk' => true,
|
||||||
'has_svk' => true,
|
'efz' => '2021-02-03',
|
||||||
'has_vk' => true,
|
'without_education_at' => '2021-02-04',
|
||||||
'efz' => '2021-02-03',
|
'without_efz_at' => '2021-02-05',
|
||||||
'without_education_at' => '2021-02-04',
|
'recertified_at' => '2021-02-08',
|
||||||
'without_efz_at' => '2021-02-05',
|
'has_nami' => false,
|
||||||
'recertified_at' => '2021-02-08',
|
'multiply_pv' => true,
|
||||||
'has_nami' => false,
|
'multiply_more_pv' => true,
|
||||||
'multiply_pv' => true,
|
'salutation' => 'Doktor',
|
||||||
'multiply_more_pv' => true,
|
]));
|
||||||
'salutation' => 'Doktor',
|
|
||||||
]));
|
|
||||||
|
|
||||||
$this->assertEquals('2021-02-01', $member->fresh()->ps_at->format('Y-m-d'));
|
$this->assertEquals('2021-02-01', $member->fresh()->ps_at->format('Y-m-d'));
|
||||||
$this->assertEquals('2021-02-02', $member->fresh()->more_ps_at->format('Y-m-d'));
|
$this->assertEquals('2021-02-02', $member->fresh()->more_ps_at->format('Y-m-d'));
|
||||||
|
|
Loading…
Reference in New Issue