123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- use PHPUnit\Framework\TestCase;
- define('APP_ID', 'test');
- 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_HELPER_PATH . '/refill/divert_account.php');
- require_once(BASE_HELPER_PATH . '/refill/store_member.php');
- class TestAccountDivert extends TestCase
- {
- public static function setUpBeforeClass(): void
- {
- Base::run_util();
- }
- public function testInitMember()
- {
- $helper = new refill\divert_account();
- $helper->init_member(65999);
- }
- //docker-compose run php php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccountDivert::testInitMerchants)( .*)?$/" --test-suffix TestAccountDivert.php /var/www/html/test
- public function testInitMerchants()
- {
- $helper = new refill\divert_account();
- $helper->init_merchants();
- }
- //docker-compose run php php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccountDivert::testInitChannels)( .*)?$/" --test-suffix TestAccountDivert.php /var/www/html/test
- public function testInitChannels()
- {
- $helper = new refill\divert_account();
- $helper->init_channels();
- }
- public function testDivertMember()
- {
- $helper = new refill\divert_account();
- $helper->add_member(60221,-100);
- }
- public function testUpdateAccount()
- {
- $stamp = 0;
- while (true)
- {
- try {
- $divertor = new refill\divert_account();
- $divertor->update_account($stamp);
- $stamp = time();
- } catch (Exception $ex) {
- Log::record($ex->getMessage(),Log::ERR);
- }
- sleep(1);
- }
- }
- //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccountDivert::testInitChannels)( .*)?$/" --test-suffix TestAccountDivert.php /var/www/html/test
- public function testInitChannelsAccount()
- {
- $helper = new refill\divert_account();
- $helper->init_channels_account();
- }
- //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccountDivert::testInitChannelsAccount)( .*)?$/" --test-suffix TestAccountDivert.php /var/www/html/test
- public function testStoreMember()
- {
- $ret = refill\store_member::instance()->get_member(13);
- $ret = refill\store_member::instance()->get_member(13);
- }
- public function testInitTimeout()
- {
- $i = 0;
- while (true)
- {
- $start = $i * 100;
- $items = Model()->table('merchant')->where(['mchid' => ['gt',0]])->field('mchid,time_out')->order('mchid asc')->limit("{$start},100")->select();
- if(empty($items)) {
- return;
- }
- $i++;
- foreach ($items as $item)
- {
- $mchid = intval($item['mchid']);
- if($mchid <= 0) continue;
- $time_out = intval($item['time_out']);
- Model()->table('merchant')->where(['mchid' => $mchid])->update(['day_timeout' => $time_out,'night_timeout' => $time_out]);
- }
- }
- }
- //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccountDivert::testInitTimeout)( .*)?$/" --test-suffix TestAccountDivert.php /var/www/html/test
- }
|