Refactor test
This commit is contained in:
parent
37cbf860d0
commit
531f44bc94
|
@ -47,8 +47,7 @@ class StoreTest extends TestCase
|
||||||
'bill_kind' => 'Post',
|
'bill_kind' => 'Post',
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$response->assertStatus(302)->assertSessionHasNoErrors();
|
$response->assertRedirect('/member')->assertSessionHasNoErrors();
|
||||||
$response->assertRedirect('/member');
|
|
||||||
$member = Member::firstWhere('firstname', 'Joe');
|
$member = Member::firstWhere('firstname', 'Joe');
|
||||||
$this->assertDatabaseHas('members', [
|
$this->assertDatabaseHas('members', [
|
||||||
'address' => 'Bavert 50',
|
'address' => 'Bavert 50',
|
||||||
|
@ -80,34 +79,19 @@ class StoreTest extends TestCase
|
||||||
|
|
||||||
public function testItCanStoreAMemberWithoutNami(): void
|
public function testItCanStoreAMemberWithoutNami(): void
|
||||||
{
|
{
|
||||||
Fee::factory()->create();
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$country = Country::factory()->create();
|
|
||||||
$gender = Gender::factory()->create();
|
|
||||||
$region = Region::factory()->create();
|
|
||||||
$nationality = Nationality::factory()->create();
|
|
||||||
$subscription = Subscription::factory()->create();
|
|
||||||
$activity = Activity::factory()->create();
|
$activity = Activity::factory()->create();
|
||||||
$subactivity = Subactivity::factory()->create();
|
$subactivity = Subactivity::factory()->create();
|
||||||
NamiPutMemberAction::allowToRun();
|
|
||||||
|
|
||||||
$response = $this
|
$response = $this
|
||||||
->from('/member/create')
|
->from('/member/create')
|
||||||
->post('/member', $this->attributes([
|
->post('/member', $this->attributes([
|
||||||
'country_id' => $country->id,
|
|
||||||
'gender_id' => $gender->id,
|
|
||||||
'region_id' => $region->id,
|
|
||||||
'nationality_id' => $nationality->id,
|
|
||||||
'first_activity_id' => $activity->id,
|
'first_activity_id' => $activity->id,
|
||||||
'first_subactivity_id' => $subactivity->id,
|
'first_subactivity_id' => $subactivity->id,
|
||||||
'subscription_id' => $subscription->id,
|
|
||||||
'bill_kind' => 'E-Mail',
|
|
||||||
'has_nami' => false,
|
'has_nami' => false,
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$response->assertStatus(302)->assertSessionHasNoErrors();
|
$response->assertSessionHasNoErrors();
|
||||||
$response->assertRedirect('/member');
|
|
||||||
$member = Member::firstWhere('firstname', 'Joe');
|
|
||||||
$this->assertDatabaseHas('members', [
|
$this->assertDatabaseHas('members', [
|
||||||
'nami_id' => null,
|
'nami_id' => null,
|
||||||
]);
|
]);
|
||||||
|
@ -116,48 +100,37 @@ class StoreTest extends TestCase
|
||||||
|
|
||||||
public function testItRequiresFields(): void
|
public function testItRequiresFields(): void
|
||||||
{
|
{
|
||||||
Fee::factory()->create();
|
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
NamiPutMemberAction::allowToRun();
|
|
||||||
|
|
||||||
$response = $this
|
$this
|
||||||
->post('/member', $this->attributes([
|
->post('/member', $this->attributes([
|
||||||
'nationality_id' => null,
|
'nationality_id' => null,
|
||||||
]));
|
]))
|
||||||
|
->assertSessionHasErrors(['nationality_id']);
|
||||||
$response->assertSessionHasErrors(['nationality_id']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubscriptionIsRequiredIfFirstActivityIsPaid(): void
|
public function testSubscriptionIsRequiredIfFirstActivityIsPaid(): void
|
||||||
{
|
{
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
Fee::factory()->create();
|
$activity = Activity::factory()->name('€ Mitglied')->create();
|
||||||
$country = Country::factory()->create();
|
|
||||||
$gender = Gender::factory()->create();
|
|
||||||
$region = Region::factory()->create();
|
|
||||||
$nationality = Nationality::factory()->create();
|
|
||||||
$subscription = Subscription::factory()->create();
|
|
||||||
$activity = Activity::factory()->create(['name' => '€ Mitglied']);
|
|
||||||
$subactivity = Subactivity::factory()->create();
|
$subactivity = Subactivity::factory()->create();
|
||||||
|
|
||||||
$response = $this
|
$this
|
||||||
->from('/member/create')
|
->from('/member/create')
|
||||||
->post('/member', $this->attributes([
|
->post('/member', $this->attributes([
|
||||||
'country_id' => $country->id,
|
|
||||||
'gender_id' => $gender->id,
|
|
||||||
'region_id' => $region->id,
|
|
||||||
'nationality_id' => $nationality->id,
|
|
||||||
'first_activity_id' => $activity->id,
|
'first_activity_id' => $activity->id,
|
||||||
'first_subactivity_id' => $subactivity->id,
|
'first_subactivity_id' => $subactivity->id,
|
||||||
'subscription_id' => null,
|
'subscription_id' => null,
|
||||||
'bill_kind' => 'E-Mail',
|
]))
|
||||||
]));
|
->assertSessionHasErrors(['subscription_id' => 'Beitragsart ist erforderlich.']);
|
||||||
|
|
||||||
$this->assertErrors(['subscription_id' => 'Beitragsart ist erforderlich.'], $response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function defaults(): array
|
public function defaults(): array
|
||||||
{
|
{
|
||||||
|
$country = Country::factory()->create();
|
||||||
|
$nationality = Nationality::factory()->create();
|
||||||
|
$subscription = Subscription::factory()->create();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'address' => 'Bavert 50',
|
'address' => 'Bavert 50',
|
||||||
'birthday' => '2013-02-19',
|
'birthday' => '2013-02-19',
|
||||||
|
@ -187,6 +160,9 @@ class StoreTest extends TestCase
|
||||||
'without_efz_at' => '',
|
'without_efz_at' => '',
|
||||||
'work_phone' => '',
|
'work_phone' => '',
|
||||||
'zip' => '42719',
|
'zip' => '42719',
|
||||||
|
'country_id' => $country->id,
|
||||||
|
'nationality_id' => $nationality->id,
|
||||||
|
'subscription_id' => $subscription->id,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue