TestAccountDivert.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 . '/refill/divert_account.php');
  9. require_once(BASE_HELPER_PATH . '/refill/store_member.php');
  10. class TestAccountDivert extends TestCase
  11. {
  12. public static function setUpBeforeClass(): void
  13. {
  14. Base::run_util();
  15. }
  16. public function testInitMember()
  17. {
  18. $helper = new refill\divert_account();
  19. $helper->init_member(65999);
  20. }
  21. //docker-compose run php php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccountDivert::testInitMerchants)( .*)?$/" --test-suffix TestAccountDivert.php /var/www/html/test
  22. public function testInitMerchants()
  23. {
  24. $helper = new refill\divert_account();
  25. $helper->init_merchants();
  26. }
  27. //docker-compose run php php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccountDivert::testInitChannels)( .*)?$/" --test-suffix TestAccountDivert.php /var/www/html/test
  28. public function testInitChannels()
  29. {
  30. $helper = new refill\divert_account();
  31. $helper->init_channels();
  32. }
  33. public function testDivertMember()
  34. {
  35. $helper = new refill\divert_account();
  36. $helper->add_member(60221,-100);
  37. }
  38. public function testUpdateAccount()
  39. {
  40. $stamp = 0;
  41. while (true)
  42. {
  43. try {
  44. $divertor = new refill\divert_account();
  45. $divertor->update_account($stamp);
  46. $stamp = time();
  47. } catch (Exception $ex) {
  48. Log::record($ex->getMessage(),Log::ERR);
  49. }
  50. sleep(1);
  51. }
  52. }
  53. //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccountDivert::testInitChannels)( .*)?$/" --test-suffix TestAccountDivert.php /var/www/html/test
  54. public function testInitChannelsAccount()
  55. {
  56. $helper = new refill\divert_account();
  57. $helper->init_channels_account();
  58. }
  59. //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccountDivert::testInitChannelsAccount)( .*)?$/" --test-suffix TestAccountDivert.php /var/www/html/test
  60. public function testStoreMember()
  61. {
  62. $ret = refill\store_member::instance()->get_member(13);
  63. $ret = refill\store_member::instance()->get_member(13);
  64. }
  65. public function testInitTimeout()
  66. {
  67. $i = 0;
  68. while (true)
  69. {
  70. $start = $i * 100;
  71. $items = Model()->table('merchant')->where(['mchid' => ['gt',0]])->field('mchid,time_out')->order('mchid asc')->limit("{$start},100")->select();
  72. if(empty($items)) {
  73. return;
  74. }
  75. $i++;
  76. foreach ($items as $item)
  77. {
  78. $mchid = intval($item['mchid']);
  79. if($mchid <= 0) continue;
  80. $time_out = intval($item['time_out']);
  81. Model()->table('merchant')->where(['mchid' => $mchid])->update(['day_timeout' => $time_out,'night_timeout' => $time_out]);
  82. }
  83. }
  84. }
  85. //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccountDivert::testInitTimeout)( .*)?$/" --test-suffix TestAccountDivert.php /var/www/html/test
  86. }