22 lines
818 B
PHP
22 lines
818 B
PHP
<?php
|
|
|
|
use App\Actions\Reports;
|
|
use App\Models\Report;
|
|
use Carbon\CarbonImmutable;
|
|
|
|
it('filters reports by kind and counts every unread one', function () {
|
|
$village = startVillage();
|
|
$at = CarbonImmutable::parse('2026-10-29 12:00:00');
|
|
foreach (['attack', 'defense', 'support', 'attack'] as $i => $type) {
|
|
Report::write($village->player_id, $type, ['n' => $i], $at->addMinutes($i));
|
|
}
|
|
|
|
$attacks = app(Reports::class)->list(owner($village), $village->world_id, 1, 'attack');
|
|
$all = app(Reports::class)->list(owner($village), $village->world_id);
|
|
|
|
expect(array_column($attacks['reports'], 'type'))->toBe(['attack', 'attack'])
|
|
->and($attacks['unread'])->toBe(4)
|
|
->and($all['reports'])->toHaveCount(4)
|
|
->and($all['reports'][0]['payload'])->toBe(['n' => 3]);
|
|
});
|