ByCacheTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace LaborReportsCountingRecordService;
  3. use App\Services\CacheService;
  4. use App\Services\LaborReportsCountingRecordService;
  5. use App\Services\OrderCountingRecordService;
  6. use Illuminate\Support\Facades\Cache;
  7. use Tests\TestCase;
  8. class ByCacheTest extends TestCase
  9. {
  10. /** @var LaborReportsCountingRecordService $laborReportsCountingRecordService */
  11. public $laborReportsCountingRecordService;
  12. public function setUp(): void
  13. {
  14. parent::setUp();
  15. $this->laborReportsCountingRecordService = new LaborReportsCountingRecordService();
  16. }
  17. public function testSet()
  18. {
  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($dateList, $unit);
  32. self::assertTrue($result['dataList']->isnotEmpty());
  33. self::assertTrue($result['dateList']==[]);
  34. }
  35. }