TestRefillCommand.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. require_once(BASE_HELPER_PATH . '/refill/ops/detail_ops.php');
  12. class TestRefillCommand extends TestCase
  13. {
  14. public static function setUpBeforeClass(): void
  15. {
  16. Base::run_util();
  17. }
  18. //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
  19. public function testRefillStat()
  20. {
  21. $dates = [
  22. '2022-10-16'
  23. ];
  24. $refill = new statistics\stat_refill();
  25. $refill->restat($dates);
  26. }
  27. //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
  28. public function testRefillStatYesterday()
  29. {
  30. Log::record("start testRefillStatYesterday",Log::DEBUG);
  31. $end_date = strtotime(date('Y-m-d',time()));
  32. $start_date = $end_date - 86400;
  33. $sDate = date('Y-m-d',$start_date);
  34. $refill = new statistics\stat_refill();
  35. $refill->restat([$sDate]);
  36. }
  37. public function testCurDate()
  38. {
  39. $end_date = strtotime(date('Y-m-d',time()));
  40. $start_date = $end_date - 86400;
  41. $clear = new refill\order_clear();
  42. $clear->clear($start_date,$end_date);
  43. $sDate = date('Y-m-d',$start_date);
  44. $refill = new statistics\stat_refill();
  45. $refill->restat([$sDate]);
  46. }
  47. //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillCommand::testFixDetailState)( .*)?$/" --test-suffix TestRefillCommand.php /var/www/html/test
  48. public function testFixDetailState()
  49. {
  50. $detail_ops = new refill\detail_ops();
  51. $detail_ops->correct_state('p202301',382586049,383016938);
  52. }
  53. }