Skip to content

Commit e59ef6b

Browse files
committed
Additional unit tests
1 parent 06eedfe commit e59ef6b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/PhpSpreadsheetTests/Calculation/CalculationTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ public function testCellWithFormulaTwoIndirect(): void
180180
self::assertEquals('9', $cell3->getCalculatedValue());
181181
}
182182

183+
public function testCellWithStringNumeric(): void
184+
{
185+
$spreadsheet = new Spreadsheet();
186+
$workSheet = $spreadsheet->getActiveSheet();
187+
$cell1 = $workSheet->getCell('A1');
188+
$cell1->setValue('+2.5');
189+
$cell2 = $workSheet->getCell('B1');
190+
$cell2->setValue('=100*A1');
191+
192+
self::assertSame(250.0, $cell2->getCalculatedValue());
193+
}
194+
183195
public function testCellWithStringFraction(): void
184196
{
185197
$spreadsheet = new Spreadsheet();

tests/PhpSpreadsheetTests/Calculation/Engine/FormattedNumberTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@
77

88
class FormattedNumberTest extends TestCase
99
{
10+
/**
11+
* @dataProvider providerNumbers
12+
*
13+
* @param mixed $expected
14+
*/
15+
public function testNumber($expected, string $value): void
16+
{
17+
FormattedNumber::convertToNumberIfFormatted($value);
18+
self::assertSame($expected, $value);
19+
}
20+
21+
public function providerNumbers(): array
22+
{
23+
return [
24+
[-12.5, '-12.5'],
25+
[-125.0, '-1.25e2'],
26+
[0.125, '12.5%'],
27+
];
28+
}
29+
1030
/**
1131
* @dataProvider providerFractions
1232
*/

0 commit comments

Comments
 (0)