TestRefillCommand.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. define('APP_ID', 'refill_stat');
  4. define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
  5. require_once(BASE_ROOT_PATH . '/global.php');
  6. require_once(BASE_CORE_PATH . '/lrlz.php');
  7. require_once(BASE_ROOT_PATH . '/fooder.php');
  8. require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
  9. require_once(BASE_HELPER_PATH . '/refill/ops/order_clear.php');
  10. require_once(BASE_HELPER_PATH . '/refill/ops/pdlog_clear.php');
  11. class TestRefillCommand extends TestCase
  12. {
  13. public static function setUpBeforeClass(): void
  14. {
  15. Base::run_util();
  16. }
  17. //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillCommand::testRefillStat)( .*)?$/" --test-suffix TestRefillCommand.php /var/www/html/test
  18. public function testRefillStat()
  19. {
  20. $dates = [
  21. '2022-10-16'
  22. ];
  23. $refill = new statistics\stat_refill();
  24. $refill->restat($dates);
  25. }
  26. //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillCommand::testRefillStatYesterday)( .*)?$/" --test-suffix TestRefillCommand.php /var/www/html/test
  27. public function testRefillStatYesterday()
  28. {
  29. Log::record("start testRefillStatYesterday",Log::DEBUG);
  30. $end_date = strtotime(date('Y-m-d',time()));
  31. $start_date = $end_date - 86400;
  32. $sDate = date('Y-m-d',$start_date);
  33. $refill = new statistics\stat_refill();
  34. $refill->restat([$sDate]);
  35. }
  36. public function testCurDate()
  37. {
  38. $end_date = strtotime(date('Y-m-d',time()));
  39. $start_date = $end_date - 86400;
  40. $clear = new refill\order_clear();
  41. $clear->clear($start_date,$end_date);
  42. $sDate = date('Y-m-d',$start_date);
  43. $refill = new statistics\stat_refill();
  44. $refill->restat([$sDate]);
  45. }
  46. }