123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- use PHPUnit\Framework\TestCase;
- define('APP_ID', 'refill_stat');
- define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
- require_once(BASE_ROOT_PATH . '/global.php');
- require_once(BASE_CORE_PATH . '/lrlz.php');
- require_once(BASE_ROOT_PATH . '/fooder.php');
- require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
- require_once(BASE_HELPER_PATH . '/refill/ops/order_clear.php');
- require_once(BASE_HELPER_PATH . '/refill/ops/pdlog_clear.php');
- require_once(BASE_HELPER_PATH . '/refill/ops/detail_ops.php');
- class TestRefillCommand extends TestCase
- {
- public static function setUpBeforeClass(): void
- {
- Base::run_util();
- }
- //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
- public function testRefillStat()
- {
- $dates = [
- '2023-03-28',
- '2023-03-29',
- '2023-03-30',
- '2023-03-31',
- ];
- $refill = new statistics\stat_refill();
- $refill->restat($dates);
- }
- //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
- public function testClearStat()
- {
- $clear_stat = function ($date)
- {
- $start_date = strtotime($date);
- $end_date = $start_date + 86400;
- $clear = new refill\order_clear();
- $clear->clear($start_date,$end_date);
- $sDate = date('Y-m-d',$start_date);
- $refill = new statistics\stat_refill();
- $refill->restat([$sDate]);
- };
- $dates = [
- '2023-04-12',
- '2023-04-14'
- ];
- foreach ($dates as $date)
- {
- $clear_stat($date);
- }
- }
- //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
- public function testRefillStatYesterday()
- {
- Log::record("start testRefillStatYesterday",Log::DEBUG);
- $end_date = strtotime(date('Y-m-d',time()));
- $start_date = $end_date - 86400;
- $sDate = date('Y-m-d',$start_date);
- $refill = new statistics\stat_refill();
- $refill->restat([$sDate]);
- }
- public function testCurDate()
- {
- $end_date = strtotime(date('Y-m-d',time()));
- $start_date = $end_date - 86400;
- $clear = new refill\order_clear();
- $clear->clear($start_date,$end_date);
- $sDate = date('Y-m-d',$start_date);
- $refill = new statistics\stat_refill();
- $refill->restat([$sDate]);
- }
- //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
- public function testFixDetailState()
- {
- $detail_ops = new refill\detail_ops();
- $detail_ops->correct_state('p202301',382586049,383016938);
- }
- }
|