mivita/tests/Feature/Incentive/RecruitingChallengeSeederTest.php
Kevin 68533e917c Recruiting Challenge: Start 9. Oktober, Texte auf EN/ES/FR
- Qualifikationsbeginn 09.10.2026 statt 01.10. (Kundenentscheid 25.09.),
  Beschreibung und Teilnahmebedingungen nennen den 9. Oktober
- Name, Untertitel, Beschreibung und Bedingungen als trans_* auf
  Englisch, Spanisch und Franzoesisch
- Seeder gleicht bei bestehender Challenge Texte, Uebersetzungen und den
  Beginn ab; alle anderen Admin-Werte bleiben

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 10:28:27 +00:00

69 lines
3.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use App\Models\Incentive;
use Database\Seeders\RecruitingChallenge2026Seeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
/**
* E1: Der Seeder legt die Recruiting Challenge mit den abgestimmten Texten als Entwurf an
* und ueberschreibt bei einem zweiten Lauf nur die Texte, nicht die Admin-Werte.
*/
it('legt die Challenge als Entwurf mit Praemie und Wertung nach Neupartnern an', function () {
$this->seed(RecruitingChallenge2026Seeder::class);
$incentive = Incentive::where('slug', RecruitingChallenge2026Seeder::SLUG)->firstOrFail();
expect($incentive->isDraft())->toBeTrue()
->and($incentive->vip_only)->toBeTrue()
->and($incentive->name)->toBe('Recruiting Challenge 2026/27')
->and($incentive->qualification_start->toDateString())->toBe('2026-10-09')
->and($incentive->qualification_end->toDateString())->toBe('2027-01-31')
->and((float) $incentive->amount_per_partner)->toBe(50.0)
->and($incentive->rankBonuses())->toBe([1 => 500.0, 2 => 300.0, 3 => 200.0])
->and($incentive->max_winners)->toBe(3)
->and($incentive->ranksByPartnerCount())->toBeTrue()
->and($incentive->hasMinimumRequirements())->toBeFalse()
->and($incentive->description)->toContain('50 €')
->and($incentive->terms)->toContain('6. Gleichstand')
->and($incentive->description.$incentive->subtitle.$incentive->terms)->not->toContain('–')
->and($incentive->description.$incentive->subtitle.$incentive->terms)->not->toContain('—')
->and($incentive->description.$incentive->terms)->toContain('9. Oktober')->not->toContain('1. Oktober');
});
it('liefert Name, Untertitel, Beschreibung und Bedingungen auf EN, ES und FR', function (string $locale, string $date) {
$this->seed(RecruitingChallenge2026Seeder::class);
$incentive = Incentive::where('slug', RecruitingChallenge2026Seeder::SLUG)->firstOrFail();
app()->setLocale($locale);
expect($incentive->getLang('subtitle'))->toContain('50')->not->toBe($incentive->subtitle)
->and($incentive->getLang('description'))->toContain($date)->not->toBe($incentive->description)
->and($incentive->getLang('terms'))->toContain($date)->toContain('6.')
->and($incentive->getLang('name'))->toBe('Recruiting Challenge 2026/27');
})->with([
'en' => ['en', '9 October'],
'es' => ['es', '9 de octubre'],
'fr' => ['fr', '9 octobre'],
]);
it('aktualisiert beim zweiten Lauf Texte und Beginn und laesst Admin-Werte stehen', function () {
$this->seed(RecruitingChallenge2026Seeder::class);
$incentive = Incentive::where('slug', RecruitingChallenge2026Seeder::SLUG)->firstOrFail();
$incentive->update([
'status' => 1, 'image' => 'challenge.jpg', 'bonus_rank_1' => 999, 'description' => 'alt',
'qualification_start' => '2026-10-01', 'trans_description' => ['en' => null, 'es' => null, 'fr' => null],
]);
$this->seed(RecruitingChallenge2026Seeder::class);
$incentive->refresh();
expect(Incentive::where('slug', RecruitingChallenge2026Seeder::SLUG)->count())->toBe(1)
->and($incentive->status)->toBe(1)
->and($incentive->image)->toBe('challenge.jpg')
->and((float) $incentive->bonus_rank_1)->toBe(999.0)
->and($incentive->description)->toContain('50 €')
->and($incentive->qualification_start->toDateString())->toBe('2026-10-09')
->and($incentive->getTrans('description', 'en'))->toContain('9 October');
});