123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?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_HELPER_PATH . '/refill/RefillFactory.php');
- require_once(BASE_HELPER_PATH . '/queue/iqueue.php');
- require_once(BASE_HELPER_PATH . '/queue/monitor.php');
- require_once(BASE_HELPER_PATH . '/refill/util.php');
- class TestRefillPolicy extends TestCase
- {
- private $mThirdJumps;
- public static function setUpBeforeClass(): void
- {
- Base::run_util();
- }
- private function getRatios()
- {
- $ins = Cache::getInstance('cacheredis');
- $content = $ins->get_org('refill_merchant_profit_ratio');
- $counts = json_decode($content,true);
- $gross = $counts['gross'];
- $detail = $counts['detail'];
- return [$gross,$detail];
- }
- public function testRatioCtl()
- {
- [$gross,$detail] = $this->getRatios();
- $ratio_ctl = new refill\mratio_controlex();
- $ratio_ctl->update($gross,$detail);
- $mchid = 10202;
- $ratio_ctl->ratio_match($mchid, 14, 4, 50, [1, 2]);
- }
- public function testThirdRetryPath()
- {
- refill\RefillFactory::instance();
- global $config;
- $this->mThirdJumps = $config['third_jumps'] ?? [];
- $next_pcoder = function ($mchid,$pcode)
- {
- if(array_key_exists($mchid,$this->mThirdJumps))
- {
- $jumps = $this->mThirdJumps[$mchid];
- if(array_key_exists($pcode,$jumps)) {
- $next_pcode = $jumps[$pcode];
- return [true,$next_pcode];
- }
- }
- return [false,''];
- };
- [$can_try,$next_pcode] = $next_pcoder(10120,'x1');
- [$can_try,$next_pcode] = $next_pcoder(10120,'x2');
- [$can_try,$next_pcode] = $next_pcoder(10120,'x3');
- }
- }
|