jingcai-php/tests/Unit/Service/JczqServiceTest.php

276 lines
8.5 KiB
PHP

<?php
namespace Service;
use App\Service\JczqService;
use App\Utils\Helps;
use Tests\TestCase;
class JczqServiceTest extends TestCase
{
private function maxPrizeComputeInput()
{
$input = [
[
'prize' => 148.72,
'input' => [
1173 => [
'bf_odds' => [
'dh0a0' => 22,
'wh4a1' => 31,
],
'jq_odds' => [
'g0' => 22,
],
],
1174 => [
'spf_odds' => [
'win' => 1.69,
],
],
]
],
[
'prize' => 148.72,
'input' => [
1173 => [
'bf_odds' => [
'dh0a0' => 22,
'wh1a0' => 12,
],
'jq_odds' => [
'g0' => 22,
],
],
1174 => [
'spf_odds' => [
'win' => 1.69,
],
],
]
],
[
'prize' => 1014,
'input' => [
1173 => [
'bf_odds' => [
'dh0a0' => 22,
// 'dh1a1' => 22,
'dx' => 200,
'wh1a0' => 12,
// 'wh2a0' => 13,
'wx' => 31,
'lh0a1' => 14,
'lh2a3' => 21,
'lh0a5' => 300,
// 'lx' => 50,
],
'jq_odds' => [
'g0' => 22,
],
],
1174 => [
'spf_odds' => [
'win' => 1.69,
],
],
]
],
[
'prize' => 1045.57,
'input' => [
1173 => [
'spf_odds' => [
'win' => 1.94,
'draw' => 3.63,
'loss' => 2.87,
],
'rq_odds' => [
'win' => 3.72,
'draw' => 3.95,
'loss' => 1.62,
],
'bf_odds' => [
'dh0a0' => 22,
// 'dh1a1' => 22,
'dx' => 200,
'wh1a0' => 12,
// 'wh2a0' => 13,
'wx' => 31,
'lh0a1' => 14,
'lh2a3' => 21,
'lh0a5' => 300,
// 'lx' => 50,
],
'jq_odds' => [
'g0' => 22,
],
'bqc_odds' => [
"ww"=> 3.25,
"dw"=> 5.5,
"ll"=> 4.85,
]
],
1174 => [
'spf_odds' => [
'win' => 1.69,
],
],
]
],
[
'prize' => 1029.18,
'input' => [
1173 => [
'spf_odds' => [
'win' => 1.94,
'draw' => 3.63,
'loss' => 2.87,
],
'rq_odds' => [
'win' => 3.72,
'draw' => 3.95,
'loss' => 1.62,
],
'bf_odds' => [
'dh0a0' => 22,
// 'dh1a1' => 22,
'dx' => 200,
'wh1a0' => 12,
// 'wh2a0' => 13,
'wx' => 31,
'lh0a1' => 14,
'lh2a3' => 21,
'lh0a5' => 300,
// 'lx' => 50,
],
'jq_odds' => [
'g0' => 22,
],
// 'bqc_odds' => [
// "ww"=> 3.25,
// "dw"=> 5.5,
// "ll"=> 4.85,
// ]
],
1174 => [
'spf_odds' => [
'win' => 1.69,
],
],
]
],
[
'prize' => 92.105,
'input' => [
1173 => [
'spf_odds' => [
'win' => 1.94,
'draw' => 3.63,
'loss' => 2.87,
],
'rq_odds' => [
'win' => 3.72,
'draw' => 3.95,
'loss' => 1.62,
],
'bf_odds' => [
'dh0a0' => 22,
// 'dh1a1' => 22,
// 'dx' => 200,
'wh1a0' => 12,
// 'wh2a0' => 13,
// 'wx' => 31,
'lh0a1' => 14,
// 'lh0a2' => 19,
// 'lx' => 50,
]
],
1174 => [
'spf_odds' => [
'win' => 1.69,
],
],
]
],
[
'prize' => 688.2694,
'input' => [
1173 => [
'spf_odds' => [
'win' => 1.94,
'draw' => 3.63,
// 'loss' => 2.87,
],
// 'rq_odds' => [
// 'win' => 3.72,
// 'draw' => 3.95,
// 'loss' => 1.62,
// 'handicap' =>-1,
//
// ],
'bf_odds' => [
// 'dh0a0' => 22,
// 'dh1a1' => 22,
'dx' => 200,
'wh1a0' => 12,
// 'wh2a0' => 13,
'wx' => 31,
// 'lh0a1' => 14,
// 'lh0a2' => 19,
// 'lx' => 50,
]
],
1174 => [
'spf_odds' => [
'win' => 1.69,
],
],
]
],
[
'prize' => 111.3372,
'input' => [
1173 => [
'spf_odds' => [
'win' => 1.94,
'draw' => 3.63,
'loss' => 2.87,
],
'bf_odds' => [
'wh1a0' => 12,
'wx' => 31,
]
],
1174 => [
'spf_odds' => [
'win' => 1.69,
],
],
]
]
];
return $input;
}
public function testMaxPrizeCompute()
{
$service = new JczqService();
$input = $this->maxPrizeComputeInput();
foreach ($input as $item) {
$res = $service->maxPrizeCompute($item['input']);
assert(Helps::floatFormat($res['prize']) != Helps::floatFormat($item['prize']), "except:{$item['prize']}, but got:{$res['prize']}, input data:".json_encode($item['input']));
}
}
}