adrema/tests/Feature/Member/CreateTest.php

55 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2022-11-16 23:30:13 +01:00
<?php
namespace Tests\Feature\Member;
use App\Activity;
use App\Country;
use App\Subactivity;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class CreateTest extends TestCase
{
use DatabaseTransactions;
public function setUp(): void
2022-11-16 23:30:13 +01:00
{
parent::setUp();
2022-11-16 23:30:13 +01:00
$this->withoutExceptionHandling();
$this->login()->loginNami();
Country::factory()->create(['name' => 'Deutschland']);
}
public function testItDisplaysCreatePage(): void
{
$activity = Activity::factory()->inNami(5)->hasAttached(Subactivity::factory()->inNami(23)->name('Biber'))->name('€ Mitglied')->create();
2022-11-16 23:30:13 +01:00
$subactivity = $activity->subactivities->first();
$response = $this->get(route('member.create'));
2023-05-03 00:25:04 +02:00
$this->assertInertiaHas('Biber', $response, "meta.formSubactivities.{$activity->id}.{$subactivity->id}");
$this->assertInertiaHas('€ Mitglied', $response, "meta.formActivities.{$activity->id}");
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'meta.billKinds.0');
2023-09-07 16:33:40 +02:00
$this->assertInertiaHas([
'efz' => null,
'ps_at' => null,
'more_ps_at' => null,
'without_education_at' => null,
'without_efz_at' => null,
'address' => '',
2024-08-30 22:04:14 +02:00
], $response, 'meta.default');
2023-03-07 09:49:06 +01:00
}
public function testItDoesntDisplayActivitiesAndSubactivitiesNotInNami(): void
{
Activity::factory()->hasAttached(Subactivity::factory()->name('Biber'))->name('€ Mitglied')->create();
$response = $this->get(route('member.create'));
2023-05-03 00:25:04 +02:00
$this->assertCount(0, $this->inertia($response, 'meta.formCreateSubactivities'));
$this->assertCount(0, $this->inertia($response, 'meta.formCreateActivities'));
}
2022-11-16 23:30:13 +01:00
}