Skip to content

Commit 1fbc5dd

Browse files
committed
Test BcMath\Number operators
1 parent 41e82cf commit 1fbc5dd

15 files changed

+495
-0
lines changed

tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTestCase.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ public function testRule(): void
2727
$this->analyse([__DIR__ . '/data/increment-decrement.php'], $this->getExpectedErrors());
2828
}
2929

30+
/**
31+
* @requires PHP >= 8.4
32+
*/
33+
public function testRuleWithBcMath(): void
34+
{
35+
$this->analyse([__DIR__ . '/data/increment-decrement-bcmath.php'], $this->getExpectedErrorsWithBcMath());
36+
}
37+
3038
/**
3139
* @return T
3240
*/
@@ -37,4 +45,9 @@ abstract protected function createRule(OperatorRuleHelper $helper): Rule;
3745
*/
3846
abstract protected function getExpectedErrors(): array;
3947

48+
/**
49+
* @return list<array{0: string, 1: int, 2?: string}>
50+
*/
51+
abstract protected function getExpectedErrorsWithBcMath(): array;
52+
4053
}

tests/Rules/Operators/OperandInArithmeticPostDecrementRuleTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,17 @@ protected function getExpectedErrors(): array
4444
];
4545
}
4646

47+
/**
48+
* {@inheritdoc}
49+
*/
50+
protected function getExpectedErrorsWithBcMath(): array
51+
{
52+
return [
53+
[
54+
'Only numeric types are allowed in post-decrement, BcMath\Number given.',
55+
8,
56+
],
57+
];
58+
}
59+
4760
}

tests/Rules/Operators/OperandInArithmeticPostIncrementRuleTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,17 @@ protected function getExpectedErrors(): array
4040
];
4141
}
4242

43+
/**
44+
* {@inheritdoc}
45+
*/
46+
protected function getExpectedErrorsWithBcMath(): array
47+
{
48+
return [
49+
[
50+
'Only numeric types are allowed in post-increment, BcMath\Number given.',
51+
12,
52+
],
53+
];
54+
}
55+
4356
}

tests/Rules/Operators/OperandInArithmeticPreDecrementRuleTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,17 @@ protected function getExpectedErrors(): array
4444
];
4545
}
4646

47+
/**
48+
* {@inheritdoc}
49+
*/
50+
protected function getExpectedErrorsWithBcMath(): array
51+
{
52+
return [
53+
[
54+
'Only numeric types are allowed in pre-decrement, BcMath\Number given.',
55+
16,
56+
],
57+
];
58+
}
59+
4760
}

tests/Rules/Operators/OperandInArithmeticPreIncrementRuleTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,17 @@ protected function getExpectedErrors(): array
4040
];
4141
}
4242

43+
/**
44+
* {@inheritdoc}
45+
*/
46+
protected function getExpectedErrorsWithBcMath(): array
47+
{
48+
return [
49+
[
50+
'Only numeric types are allowed in pre-increment, BcMath\Number given.',
51+
20,
52+
],
53+
];
54+
}
55+
4356
}

tests/Rules/Operators/OperandInArithmeticUnaryMinusRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,12 @@ public function testRule(): void
3131
]);
3232
}
3333

34+
/**
35+
* @requires PHP >= 8.4
36+
*/
37+
public function testRuleWithBcMath(): void
38+
{
39+
$this->analyse([__DIR__ . '/data/operators-bcmath.php'], []);
40+
}
41+
3442
}

tests/Rules/Operators/OperandInArithmeticUnaryPlusRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,12 @@ public function testRule(): void
3131
]);
3232
}
3333

34+
/**
35+
* @requires PHP >= 8.4
36+
*/
37+
public function testRuleWithBcMath(): void
38+
{
39+
$this->analyse([__DIR__ . '/data/operators-bcmath.php'], []);
40+
}
41+
3442
}

tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,25 @@ public function testRule(): void
6060
$this->analyse([__DIR__ . '/data/operators.php'], $messages);
6161
}
6262

63+
/**
64+
* @requires PHP >= 8.4
65+
*/
66+
public function testRuleWithBcMath(): void
67+
{
68+
$this->analyse([__DIR__ . '/data/operators-bcmath.php'], [
69+
[
70+
'Only numeric types are allowed in +, null given on the right side.',
71+
36,
72+
],
73+
[
74+
'Only numeric types are allowed in +, null given on the left side.',
75+
37,
76+
],
77+
[
78+
'Only numeric types are allowed in +, null given on the right side.',
79+
157,
80+
],
81+
]);
82+
}
83+
6384
}

tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,25 @@ public function testRule(): void
4343
]);
4444
}
4545

46+
/**
47+
* @requires PHP >= 8.4
48+
*/
49+
public function testRuleWithBcMath(): void
50+
{
51+
$this->analyse([__DIR__ . '/data/operators-bcmath.php'], [
52+
[
53+
'Only numeric types are allowed in /, null given on the right side.',
54+
96,
55+
],
56+
[
57+
'Only numeric types are allowed in /, null given on the left side.',
58+
97,
59+
],
60+
[
61+
'Only numeric types are allowed in /, null given on the right side.',
62+
217,
63+
],
64+
]);
65+
}
66+
4667
}

tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,25 @@ public function testRule(): void
4343
]);
4444
}
4545

46+
/**
47+
* @requires PHP >= 8.4
48+
*/
49+
public function testRuleWithBcMath(): void
50+
{
51+
$this->analyse([__DIR__ . '/data/operators-bcmath.php'], [
52+
[
53+
'Only numeric types are allowed in **, null given on the right side.',
54+
116,
55+
],
56+
[
57+
'Only numeric types are allowed in **, null given on the left side.',
58+
117,
59+
],
60+
[
61+
'Only numeric types are allowed in **, null given on the right side.',
62+
237,
63+
],
64+
]);
65+
}
66+
4667
}

0 commit comments

Comments
 (0)