TestRefillCommand.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. '2024-07-20',
  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::testClearStat)( .*)?$/" --test-suffix TestRefillCommand.php /var/www/html/test
  28. public function testClearStat()
  29. {
  30. $clear_stat = function ($date)
  31. {
  32. $start_date = strtotime($date);
  33. $end_date = $start_date + 86400;
  34. $clear = new refill\order_clear();
  35. $clear->clear($start_date,$end_date);
  36. $sDate = date('Y-m-d',$start_date);
  37. $refill = new statistics\stat_refill();
  38. $refill->restat([$sDate]);
  39. };
  40. $dates = [
  41. '2023-04-12',
  42. '2023-04-14'
  43. ];
  44. foreach ($dates as $date)
  45. {
  46. $clear_stat($date);
  47. }
  48. }
  49. //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
  50. public function testRefillStatYesterday()
  51. {
  52. Log::record("start testRefillStatYesterday",Log::DEBUG);
  53. $end_date = strtotime(date('Y-m-d',time()));
  54. $start_date = $end_date - 86400;
  55. $sDate = date('Y-m-d',$start_date);
  56. $refill = new statistics\stat_refill();
  57. $refill->restat([$sDate]);
  58. }
  59. public function testCurDate()
  60. {
  61. $end_date = strtotime(date('Y-m-d',time()));
  62. $start_date = $end_date - 86400;
  63. $clear = new refill\order_clear();
  64. $clear->clear($start_date,$end_date);
  65. $sDate = date('Y-m-d',$start_date);
  66. $refill = new statistics\stat_refill();
  67. $refill->restat([$sDate]);
  68. }
  69. //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
  70. public function testFixDetailState()
  71. {
  72. $detail_ops = new refill\detail_ops();
  73. $detail_ops->correct_state('p202301',382586049,383016938);
  74. }
  75. }