<?php

namespace LaborReportsCountingRecordService;

use App\Services\LaborReportsCountingRecordService;
use Illuminate\Support\Facades\Cache;
use Tests\TestCase;

class ByCacheTest extends TestCase
{
    /** @var LaborReportsCountingRecordService $laborReportsCountingRecordService */
    public $laborReportsCountingRecordService;

    public function setUp(): void
    {
        parent::setUp();
        $this->laborReportsCountingRecordService = new LaborReportsCountingRecordService();
    }

    public function testSet()
    {
        $dateList = [
            '2025-10-01',
            '2025-10-02',
            '2025-10-03',
            '2025-10-04',
            '2025-10-05',
        ];
        $unit = '日';
        foreach ($dateList as $date) {
            $key = 'laborReportsCountingRecords_' . $date . '_' . $unit;
            Cache::put($key, '111111111111');
        }
        $result = $this->laborReportsCountingRecordService->getByCache($dateList, $unit);

        self::assertTrue($result['dataList']->isnotEmpty());
        self::assertTrue($result['dateList']==[]);
    }
}
