Mod member ShowTest
This commit is contained in:
parent
75130fc794
commit
cbd6fe9b0f
|
@ -18,7 +18,7 @@ class MemberShowAction
|
|||
public function handle(Member $member): array
|
||||
{
|
||||
return [
|
||||
'data' => new MemberResource($member->load('memberships')),
|
||||
'data' => new MemberResource($member->load('memberships')->load('payments.subscription')),
|
||||
'toolbar' => [['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'undo']],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ class PaymentResource extends JsonResource
|
|||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'subscription_id' => $this->subscription_id,
|
||||
'subscription_name' => $this->subscription->name,
|
||||
'subscription' => new SubscriptionResource($this->whenLoaded('subscription')),
|
||||
'status_name' => $this->status->name,
|
||||
'status_id' => $this->status->id,
|
||||
'nr' => $this->nr,
|
||||
|
|
|
@ -40,7 +40,7 @@ class PaymentFactory extends Factory
|
|||
public function subscription(string $name, int $amount): self
|
||||
{
|
||||
return $this->for(
|
||||
Subscription::factory()->state(['name' => $name, 'amount' => $amount])->for(Fee::first()),
|
||||
Subscription::factory()->state(['name' => $name, 'amount' => $amount])->for(Fee::factory())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Tests\Feature\Member;
|
|||
|
||||
use App\Member\Member;
|
||||
use App\Member\Membership;
|
||||
use App\Payment\Payment;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
@ -16,6 +17,7 @@ class ShowTest extends TestCase
|
|||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$member = Member::factory()
|
||||
->has(Membership::factory()->in('€ LeiterIn', 5, 'Jungpfadfinder', 88)->state(['created_at' => '2022-11-19 05:00:00']))
|
||||
->has(Payment::factory()->notPaid()->nr('2019')->subscription('Free', 1050))
|
||||
->defaults()->create(['firstname' => 'Max']);
|
||||
|
||||
$response = $this->get("/member/{$member->id}");
|
||||
|
@ -26,5 +28,14 @@ class ShowTest extends TestCase
|
|||
'id' => $member->memberships->first()->id,
|
||||
'human_date' => '19.11.2022',
|
||||
], $response, 'data.memberships.0');
|
||||
$this->assertInertiaHas([
|
||||
'subscription' => [
|
||||
'name' => 'Free',
|
||||
'id' => $member->payments->first()->subscription->id,
|
||||
'amount' => 1050,
|
||||
],
|
||||
'status_name' => 'Nicht bezahlt',
|
||||
'nr' => '2019',
|
||||
], $response, 'data.payments.0');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue