TestRefillStats.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. define('APP_ID', 'test');
  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_HELPER_PATH . '/stat_helper.php');
  9. class TestRefillStats extends TestCase
  10. {
  11. public static function setUpBeforeClass(): void
  12. {
  13. Base::run_util();
  14. }
  15. public function testLatestDay()
  16. {
  17. $refill = new statistics\stat_refill();
  18. $refill->run();
  19. }
  20. public function testReload()
  21. {
  22. $refill = new statistics\stat_refill();
  23. $task_id = 8;
  24. $mod_task = Model('task');
  25. $item = $mod_task->where(['task_id' => $task_id])->find();
  26. $condition = unserialize($item['params']);
  27. $type = $condition['type'];
  28. $time_stamp = $condition['time_stamp'];
  29. $cid = $condition['cid'];
  30. $order_time_type = $condition['order_time_type'];
  31. if ($type == 'merchant') {
  32. $refill->merchant_stat($time_stamp, $cid, $order_time_type);
  33. } elseif ($type == 'provider') {
  34. $refill->provider_stat($time_stamp, $cid, $order_time_type);
  35. }
  36. }
  37. }
  38. //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillStats::testLatestDay)( .*)?$/" --test-suffix TestRefillStats.php /var/www/html/test