withoutExceptionHandling()->login()->loginNami(); $fee = Fee::factory()->create(); $response = $this->from('/subscription')->post( '/subscription', SubscriptionRequestFactory::new()->fee($fee)->name('lorem')->children([ new Child('ch', 2500), ])->create() ); $response->assertRedirect('/subscription'); $subscription = Subscription::firstWhere('name', 'lorem'); $this->assertDatabaseHas('subscriptions', [ 'fee_id' => $fee->id, 'name' => 'lorem', ]); $this->assertDatabaseHas('subscription_children', [ 'name' => 'ch', 'amount' => 2500, 'parent_id' => $subscription->id, ]); } public function testItValidatesSubscription(): void { $this->login()->loginNami(); Fee::factory()->create(); $response = $this->post( '/subscription', SubscriptionRequestFactory::new()->invalid()->create() ); $this->assertErrors([ 'fee_id' => 'Nami-Beitrag ist nicht vorhanden.', 'name' => 'Name ist erforderlich.', ], $response); } }