TestRefillBalance.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. define('APP_ID', 'balance');
  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 . '/statistics/refill_balance.php');
  9. class TestRefillBalance extends TestCase
  10. {
  11. public static function setUpBeforeClass(): void
  12. {
  13. Base::run_util();
  14. }
  15. public function testAddBalance()
  16. {
  17. $refill_balance = new statistics\refill_balance();
  18. $refill_balance->add_balance('system', 0, 0, strtotime('2021-12-01'),'order_time');
  19. }
  20. //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillBalance::testInitBalance)( .*)?$/" --test-suffix TestRefillBalance.php /var/www/html/test
  21. public function testInitBalance()
  22. {
  23. $refill_balance = new statistics\refill_balance();
  24. $refill_balance->stat_all(0, strtotime('2022-01-15'));
  25. }
  26. public function testSomething()
  27. {
  28. $checker = function ($cfg)
  29. {
  30. if(!empty($cfg['segment']))
  31. {
  32. $segment = $cfg['segment'];
  33. $sitems = explode(',',$segment);
  34. $tmp = [];
  35. foreach ($sitems as $sitem)
  36. {
  37. $sitem = trim($sitem);
  38. if(!empty($sitem)) {
  39. $tmp[] = $sitem;
  40. }
  41. }
  42. if(!empty($tmp)) {
  43. $cfg['segment'] = implode('|',$tmp);
  44. }
  45. }
  46. return $cfg;
  47. };
  48. $cfg['segment'] = '133,139,147,,';
  49. $acfg = $checker($cfg);
  50. $reg = "/^(?:{$acfg['segment']})\d*$/";
  51. // $x = preg_match('/^(?:139)\d{8}$/', 13911129866, $matches);
  52. $x = preg_match($reg, 13911129866, $matches);
  53. }
  54. }