ByCacheTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace LaborReportsCountingRecordService;
  3. use App\Services\LaborReportsCountingRecordService;
  4. use Illuminate\Support\Facades\Cache;
  5. use Tests\TestCase;
  6. class ByCacheTest extends TestCase
  7. {
  8. /** @var LaborReportsCountingRecordService $laborReportsCountingRecordService */
  9. public $laborReportsCountingRecordService;
  10. public function setUp(): void
  11. {
  12. parent::setUp();
  13. $this->laborReportsCountingRecordService = new LaborReportsCountingRecordService();
  14. }
  15. public function testSet()
  16. {
  17. $dateList = [
  18. '2025-10-01',
  19. '2025-10-02',
  20. '2025-10-03',
  21. '2025-10-04',
  22. '2025-10-05',
  23. ];
  24. $unit = '日';
  25. foreach ($dateList as $date) {
  26. $key = 'laborReportsCountingRecords_' . $date . '_' . $unit;
  27. Cache::put($key, '111111111111');
  28. }
  29. $result = $this->laborReportsCountingRecordService->getByCache($dateList, $unit);
  30. self::assertTrue($result['dataList']->isnotEmpty());
  31. self::assertTrue($result['dateList']==[]);
  32. }
  33. }