Skip to content

Commit 87147c5

Browse files
committed
Minor Coverage Improvements
1 parent 8175944 commit 87147c5

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,13 +1236,16 @@ private function internalParseFormula(string $formula, ?Cell $cell = null): bool
12361236
// because at least the braces are paired up (at this stage in the formula)
12371237
// MS Excel allows this if the content is cell references; but doesn't allow actual values,
12381238
// but at this point, we can't differentiate (so allow both)
1239-
//return $this->raiseFormulaError('Formula Error: Unexpected ,');
1239+
return $this->raiseFormulaError('Formula Error: Unexpected ,');
1240+
/* The following code may be a better choice, but, with
1241+
the other changes for this PR, I can no longer come up
1242+
with a test case that gets here
12401243
$stack->push('Binary Operator', '∪');
12411244
12421245
++$index;
12431246
$expectingOperator = false;
12441247
1245-
continue;
1248+
continue;*/
12461249
}
12471250

12481251
/** @var array<string, int> $d */
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpOffice\PhpSpreadsheetTests\Cell;
6+
7+
use PhpOffice\PhpSpreadsheet\Cell\Cell;
8+
use PHPUnit\Framework\Attributes\DataProvider;
9+
use PHPUnit\Framework\TestCase;
10+
use ReflectionMethod;
11+
12+
class ConvertSpecialArrayTest extends TestCase
13+
{
14+
/**
15+
* @param mixed[] $expected
16+
* @param mixed[] $inArray
17+
*/
18+
#[DataProvider('providerSpecialArrays')]
19+
public function testConvertSpecialArray(array $expected, array $inArray): void
20+
{
21+
$reflectionMethod = new ReflectionMethod(Cell::class, 'convertSpecialArray');
22+
$result = $reflectionMethod->invokeArgs(null, [$inArray]);
23+
self::assertSame($expected, $result);
24+
}
25+
26+
public static function providerSpecialArrays(): array
27+
{
28+
return [
29+
'expected form row index to array indexed by column' => [
30+
[
31+
[1, 2],
32+
[3, 4],
33+
],
34+
[
35+
1 => ['A' => 1, 'B' => 2],
36+
2 => ['A' => 3, 'B' => 4],
37+
],
38+
],
39+
'standard array unchanged' => [
40+
[
41+
1 => [1, 2],
42+
2 => [3, 4],
43+
],
44+
[
45+
1 => [1, 2],
46+
2 => [3, 4],
47+
],
48+
],
49+
'uses index 0 so unchanged' => [
50+
[
51+
['A' => 1, 'B' => 2],
52+
['A' => 3, 'B' => 4],
53+
],
54+
[
55+
['A' => 1, 'B' => 2],
56+
['A' => 3, 'B' => 4],
57+
],
58+
],
59+
];
60+
}
61+
}

0 commit comments

Comments
 (0)