Files
lotteryLaravel/tests/Feature/SettlementMatcherRegistryCompletenessTest.php

34 lines
1.3 KiB
PHP

<?php
use App\Models\PlayType;
use Database\Seeders\PlayTypeSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Services\Settlement\SettlementMatcherRegistry;
use App\Services\Settlement\Matchers\NoopSettlementMatcher;
uses(RefreshDatabase::class);
beforeEach(fn () => $this->seed(PlayTypeSeeder::class));
test('every enabled play type maps to a non-noop settlement matcher', function (): void {
$reg = app(SettlementMatcherRegistry::class);
foreach (PlayType::query()->where('is_enabled', true)->orderBy('play_code')->pluck('play_code') as $code) {
$matcher = $reg->for((string) $code);
expect($matcher)->not->toBeInstanceOf(NoopSettlementMatcher::class);
}
});
test('independent draw plays stay disabled until their settlement matchers exist', function (): void {
$reg = app(SettlementMatcherRegistry::class);
foreach (['five_d', 'six_d'] as $code) {
expect(PlayType::query()->where('play_code', $code)->value('is_enabled'))->toBeFalse()
->and($reg->for($code))->toBeInstanceOf(NoopSettlementMatcher::class);
}
});
test('half_box reuses the same matcher instance as big spread', function (): void {
$reg = app(SettlementMatcherRegistry::class);
expect($reg->for('half_box'))->toBe($reg->for('big'));
});