'DE', 'phone' => '49', 'en' => 'Germany', 'de' => 'Deutschland', 'es' => 'Alemania', 'fr' => 'Allemagne', 'it' => 'Germania', 'ru' => 'Германия', ]); $consultant = User::forceCreate([ 'email' => 'co-calc-'.uniqid('', true).'@example.com', 'password' => bcrypt('secret'), 'lang' => 'de', ]); $shoppingUser = ShoppingUser::create([ 'auth_user_id' => $consultant->id, 'member_id' => $consultant->id, 'billing_country_id' => $country->id, 'shipping_country_id' => $country->id, 'billing_email' => 'me-'.uniqid('', true).'@example.com', 'is_from' => 'wizard', ]); $userAbo = UserAbo::create([ 'user_id' => $consultant->id, 'member_id' => null, 'shopping_user_id' => $shoppingUser->id, 'is_for' => 'me', 'email' => $shoppingUser->billing_email, 'payone_userid' => 999002, 'clearingtype' => 'cc', 'active' => true, 'status' => 2, 'abo_interval' => 1, ]); $userAbo->forceFill([ 'created_at' => Carbon::parse('2026-01-15 12:00:00'), 'updated_at' => Carbon::parse('2026-01-15 12:00:00'), ])->save(); $incentive = Incentive::factory()->create([ 'qualification_start' => '2026-04-01', 'qualification_end' => '2026-07-31', 'calculation_end' => '2026-08-31', 'status' => 1, 'points_abo_onetime' => 400, ]); $participant = IncentiveParticipant::factory()->create([ 'incentive_id' => $incentive->id, 'user_id' => $consultant->id, ]); $exitCode = Artisan::call('incentive:calculate', [ 'incentive_id' => (string) $incentive->id, ]); expect($exitCode)->toBe(0); $participant->refresh(); expect( IncentiveNewAbo::query() ->where('participant_id', $participant->id) ->where('user_abo_id', $userAbo->id) ->exists() )->toBeTrue(); $log = IncentivePointsLog::query() ->where('participant_id', $participant->id) ->where('type', 'abo') ->where('source_id', $userAbo->id) ->first(); expect($log)->not->toBeNull() ->and($log->month)->toBe(4) ->and($log->year)->toBe(2026) ->and($log->points_onetime)->toBe(400); expect($participant->total_points)->toBe(400); });