| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace Tests\Unit;
- use PHPUnit\Framework\TestCase;
- class SharingFootballSettlementTest extends TestCase
- {
- protected function setUp(): void
- {
- parent::setUp();
- require_once dirname(__DIR__, 3) . '/melbet_sport-api/app/common/service/FootballSettlementService.php';
- }
- /** @dataProvider footballOutcomes */
- public function test_actual_wallet_return_includes_unlost_principal(string $selection, string $expectedProfit, string $expectedPayout): void
- {
- $detail = ['odds' => [['values' => [['value' => $selection, 'odd' => '1.80']]]]];
- $result = \app\common\service\FootballSettlementService::totalHomeOrAway('100.00', 2, $detail);
- $result['amount'] = '100.00';
- $this->assertEquals($expectedProfit, $result['profit_and_loss']);
- $this->assertSame($expectedPayout, \app\common\service\FootballSettlementService::payoutAmount($result));
- }
- public function footballOutcomes(): array
- {
- return [
- ['Over 1.5', '80', '180.00'],
- ['Over 1.75', '40', '140.00'],
- ['Over 2', '0', '100.00'],
- ['Over 2.25', '-50', '50.00'],
- ['Over 2.5', '-100', '0.00'],
- ];
- }
- public function test_generic_draw_result_exposes_the_principal_refund(): void
- {
- $result = \app\common\service\FootballSettlementService::getResult(2, '100.00', '1.80');
- $this->assertSame('100.00', $result['return_amount']);
- $this->assertSame('100.00', \app\common\service\FootballSettlementService::payoutAmount($result + ['amount' => '100.00']));
- }
- }
|