TestMixedMatch.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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/policy/match/ImateTester.php');
  9. //require_once(BASE_HELPER_PATH . '/refill/policy/match/mixed_match.php');
  10. //require_once(BASE_HELPER_PATH . '/refill/policy/match/whole_match.php');
  11. //require_once(BASE_HELPER_PATH . '/refill/policy/match/type_match.php');
  12. //require_once(BASE_HELPER_PATH . '/refill/policy/match/type_spec_match.php');
  13. require_once(BASE_HELPER_PATH . '/refill/XYZRefillFactory.php');
  14. class TestMixedMatch extends TestCase
  15. {
  16. public static function setUpBeforeClass(): void
  17. {
  18. Base::run_util();
  19. }
  20. public function testImate()
  21. {
  22. $imate = new refill\ImateTester();
  23. $imate->load();
  24. // $content = "{\"gross\": {\"10131\": [157690, 54, 157636, 0.34, 24.19, 0.005973]}, \"detail\": {\"10131-5-30\": [143, 5, 138, 0.03497, 1.44, 0.0096], \"10131-6-100\": [65, 0, 65, 0.0, 0.0, 0.0], \"10131-5-100\": [13, 2, 11, 0.15385, 1.0, 0.005], \"10131-6-50\": [0, 0, 0, 0.0, 0.0, 0.0], \"10131-4-50\": [52224, 20, 52204, 0.00038, 9.25, 0.00925], \"10131-4-100\": [105233, 27, 105206, 0.00026, 12.5, 0.00463], \"10131-5-50\": [6, 0, 6, 0.0, 0.0, 0.0], \"10131-4-30\": [6, 0, 6, 0.0, 0.0, 0.0]}, \"types\": {\"10131-5\": [162, 7, 155, 0.04321, 2.44, 0.006971], \"10131-6\": [65, 0, 65, 0.0, 0.0, 0.0], \"10131-4\": [157463, 47, 157416, 0.000298, 21.75, 0.005878]}}";
  25. $content = "{\"gross\": {\"10131\": [157690, 54, 157636, 0.21, 24.19, 0.005973]}, \"detail\": {\"10131-5-30\": [143, 5, 138, 0.03497, 1.44, 0.0096], \"10131-6-100\": [65, 0, 65, 0.0, 0.0, 0.0], \"10131-5-100\": [13, 2, 11, 0.15385, 1.0, 0.005], \"10131-6-50\": [0, 0, 0, 0.0, 0.0, 0.0], \"10131-4-50\": [52224, 20, 52204, 0.00038, 9.25, 0.00925], \"10131-4-100\": [105233, 27, 105206, 0.00026, 12.5, 0.00463], \"10131-5-50\": [6, 0, 6, 0.0, 0.0, 0.0], \"10131-4-30\": [6, 0, 6, 0.0, 0.0, 0.0]}, \"types\": {\"10131-5\": [162, 7, 155, 0.21321, 2.44, 0.006971], \"10131-6\": [65, 0, 65, 0.0, 0.0, 0.0], \"10131-4\": [157463, 47, 157416, 0.208, 21.75, 0.005878]}}";
  26. $counts = json_decode($content,true);
  27. $gross = $counts['gross'];
  28. $detail = $counts['detail'];
  29. $types = $counts['types'];
  30. $imate->update($gross, $detail, $types);
  31. [$match,$can_last] = $imate->ratio_match(10131, 14, 5, 30, [1, 2]);
  32. Log::record("match={$match},can_last={$can_last}",Log::DEBUG);
  33. }
  34. public function testFactory()
  35. {
  36. $content = "{\"gross\": {\"10131\": [157690, 54, 157636, 0.21, 24.19, 0.005973]}, \"detail\": {\"10131-5-30\": [143, 5, 138, 0.03497, 1.44, 0.0096], \"10131-6-100\": [65, 0, 65, 0.0, 0.0, 0.0], \"10131-5-100\": [13, 2, 11, 0.15385, 1.0, 0.005], \"10131-6-50\": [0, 0, 0, 0.0, 0.0, 0.0], \"10131-4-50\": [52224, 20, 52204, 0.00038, 9.25, 0.00925], \"10131-4-100\": [105233, 27, 105206, 0.00026, 12.5, 0.00463], \"10131-5-50\": [6, 0, 6, 0.0, 0.0, 0.0], \"10131-4-30\": [6, 0, 6, 0.0, 0.0, 0.0]}, \"types\": {\"10131-5\": [162, 7, 155, 0.21321, 2.44, 0.006971], \"10131-6\": [65, 0, 65, 0.0, 0.0, 0.0], \"10131-4\": [157463, 47, 157416, 0.208, 21.75, 0.005878]}}";
  37. $counts = json_decode($content,true);
  38. $gross = $counts['gross'];
  39. $detail = $counts['detail'];
  40. $types = $counts['types'];
  41. refill\RefillFactory::instance()->UpdateMchRatios($gross,$detail,$types);
  42. }
  43. }