Skip to content

Commit

Permalink
再現テスト追加
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Feb 4, 2024
1 parent ae08724 commit f99e6c0
Showing 1 changed file with 166 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ public function testGetTaxPerTaxRateWithRound()
self::assertSame(
[
8 => [
'discount' => 596,
'total' => 65160,
'tax' => 4827
],
10 => [
'discount' => 6563,
'total' => 717868,
'tax' => 65261
]
Expand Down Expand Up @@ -86,10 +88,12 @@ public function testGetTaxPerTaxRateWithZero()
self::assertSame(
[
8 => [
'discount' => 0,
'total' => 0,
'tax' => 0
],
10 => [
'discount' => 0,
'total' => 0,
'tax' => 0
]
Expand Down Expand Up @@ -137,16 +141,20 @@ public function testGetTaxPerTaxRateWithFloor()
self::assertSame(
[
8 => [
'discount' => 596,
'total' => 65160,
'tax' => 4826
],
10 => [
'total' => 717867,
'discount' => 6563,
'total' => 717868,
'tax' => 65260
]
],
$actual
);

self::assertSame(array_sum($arrTaxableTotal) - $discount_total, $actual[8]['total'] + $actual[10]['total']);
}

/**
Expand Down Expand Up @@ -182,16 +190,172 @@ public function testGetTaxPerTaxRateWithCeil()
self::assertSame(
[
8 => [
'total' => 65161,
'discount' => 596,
'total' => 65160,
'tax' => 4827
],
10 => [
'discount' => 6563,
'total' => 717868,
'tax' => 65261
]
],
$actual
);

self::assertSame(array_sum($arrTaxableTotal) - $discount_total, $actual[8]['total'] + $actual[10]['total']);
}

/**
* @see https://github.com/EC-CUBE/ec-cube2/pull/762#issuecomment-1897799676
*/
public function testGetTaxPerTaxRateWithRound2()
{
$this->setUpTaxRule([
[
'tax_rule_id' => 1004,
'apply_date' => '2019-10-01 00:00:00',
'tax_rate' => '10',
'calc_rule' => '1',
'product_id' => '0',
'product_class_id' => '0',
'del_flg' => '0',
'member_id' => 1,
'create_date' => '2000-01-01 00:00:00',
'update_date' => '2000-01-01 00:00:00',
],
]);

$arrTaxableTotal = [
10 => 1595,
8 => 7398,
];
$discount_total = 92;

$actual = SC_Helper_TaxRule_Ex::getTaxPerTaxRate($arrTaxableTotal, $discount_total);
self::assertSame(
[
8 => [
'discount' => 76,
'total' => 7322,
'tax' => 542
],
10 => [
'discount' => 16,
'total' => 1579,
'tax' => 144
]
],
$actual
);

self::assertSame(
'(8%対象: 7,322円 内消費税: 542円)'.PHP_EOL.
'(10%対象: 1,579円 内消費税: 144円)'.PHP_EOL,
SC_Helper_TaxRule_Ex::getTaxDetail($arrTaxableTotal, $discount_total)
);

self::assertSame(array_sum($arrTaxableTotal) - $discount_total, $actual[8]['total'] + $actual[10]['total']);
}

/**
* @see https://github.com/EC-CUBE/ec-cube2/pull/762#issuecomment-1897799676
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testGetTaxPerTaxRateWithFloor2()
{
self::markTestSkipped('Skip this test because @runInSeparateProcess does not work properly');

$this->setUpTaxRule([
[
'tax_rule_id' => 1004,
'apply_date' => '2019-10-01 00:00:00',
'tax_rate' => '10',
'calc_rule' => '2', // floor
'product_id' => '0',
'product_class_id' => '0',
'del_flg' => '0',
'member_id' => 1,
'create_date' => '2000-01-01 00:00:00',
'update_date' => '2000-01-01 00:00:00',
],
]);

$arrTaxableTotal = [
10 => 1595,
8 => 7398,
];
$discount_total = 92;

$actual = SC_Helper_TaxRule_Ex::getTaxPerTaxRate($arrTaxableTotal, $discount_total);
self::assertSame(
[
8 => [
'discount' => 76,
'total' => 7322,
'tax' => 542
],
10 => [
'discount' => 16,
'total' => 1579,
'tax' => 143
]
],
$actual
);

self::assertSame(array_sum($arrTaxableTotal) - $discount_total, $actual[8]['total'] + $actual[10]['total']);
}

/**
* @see https://github.com/EC-CUBE/ec-cube2/pull/762#issuecomment-1897799676
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testGetTaxPerTaxRateWithCeil2()
{
self::markTestSkipped('Skip this test because @runInSeparateProcess does not work properly');

$this->setUpTaxRule([
[
'tax_rule_id' => 1004,
'apply_date' => '2019-10-01 00:00:00',
'tax_rate' => '10',
'calc_rule' => '3', // ceil
'product_id' => '0',
'product_class_id' => '0',
'del_flg' => '0',
'member_id' => 1,
'create_date' => '2000-01-01 00:00:00',
'update_date' => '2000-01-01 00:00:00',
],
]);

$arrTaxableTotal = [
10 => 1595,
8 => 7398,
];
$discount_total = 92;

$actual = SC_Helper_TaxRule_Ex::getTaxPerTaxRate($arrTaxableTotal, $discount_total);
self::assertSame(
[
8 => [
'discount' => 76,
'total' => 7322,
'tax' => 543
],
10 => [
'discount' => 16,
'total' => 1579,
'tax' => 144
]
],
$actual
);

self::assertSame(array_sum($arrTaxableTotal) - $discount_total, $actual[8]['total'] + $actual[10]['total']);
}

protected function setUpTaxRule(array $taxs = [])
Expand Down

0 comments on commit f99e6c0

Please sign in to comment.