mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-31 04:28:51 +00:00
Additional unit tests
This commit is contained in:
@@ -180,6 +180,18 @@ class CalculationTest extends TestCase
|
||||
self::assertEquals('9', $cell3->getCalculatedValue());
|
||||
}
|
||||
|
||||
public function testCellWithStringNumeric(): void
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$workSheet = $spreadsheet->getActiveSheet();
|
||||
$cell1 = $workSheet->getCell('A1');
|
||||
$cell1->setValue('+2.5');
|
||||
$cell2 = $workSheet->getCell('B1');
|
||||
$cell2->setValue('=100*A1');
|
||||
|
||||
self::assertSame(250.0, $cell2->getCalculatedValue());
|
||||
}
|
||||
|
||||
public function testCellWithStringFraction(): void
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
@@ -7,6 +7,26 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FormattedNumberTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerNumbers
|
||||
*
|
||||
* @param mixed $expected
|
||||
*/
|
||||
public function testNumber($expected, string $value): void
|
||||
{
|
||||
FormattedNumber::convertToNumberIfFormatted($value);
|
||||
self::assertSame($expected, $value);
|
||||
}
|
||||
|
||||
public function providerNumbers(): array
|
||||
{
|
||||
return [
|
||||
[-12.5, '-12.5'],
|
||||
[-125.0, '-1.25e2'],
|
||||
[0.125, '12.5%'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFractions
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user