ByCacheTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. $start = '2025-10-01';
  18. $end = '2025-10-05';
  19. $dateList = [
  20. '2025-10-01',
  21. '2025-10-02',
  22. '2025-10-03',
  23. '2025-10-04',
  24. '2025-10-05',
  25. ];
  26. $unit = '日';
  27. foreach ($dateList as $date) {
  28. $key = 'laborReportsCountingRecords_' . $date . '_' . $unit;
  29. Cache::put($key, '111111111111');
  30. }
  31. $result = $this->laborReportsCountingRecordService->getByCache($start,$end, $unit);
  32. self::assertTrue($result['dataList']->isnotEmpty());
  33. self::assertTrue($result['dateList'] == []);
  34. }
  35. }