TestRefillCommand.php 3.1 KB

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