mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-20 15:16:36 +00:00
79fca7601c
This came to light while cleaning up ComplexAssert. Many tests are calling `_calculateFormulaValue` rather than `calculateFormula`, and, as a result, have to be trimmed before asserting. This PR changes those calls, and does a bit more to simplify the tests. There are a lot of other non-Engineering tests which call `_calculateFormulaValue`, but none of those need to manipulate the result after the test. This PR changes only tests, no source code.
33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalcException;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class CalculationErrorTest extends TestCase
|
|
{
|
|
public function testCalculationExceptionSuppressed(): void
|
|
{
|
|
$calculation = Calculation::getInstance();
|
|
self::assertFalse($calculation->getSuppressFormulaErrors());
|
|
$calculation->setSuppressFormulaErrors(true);
|
|
$result = $calculation->calculateFormula('=SUM(');
|
|
$calculation->setSuppressFormulaErrors(false);
|
|
self::assertFalse($result);
|
|
}
|
|
|
|
public function testCalculationException(): void
|
|
{
|
|
$calculation = Calculation::getInstance();
|
|
self::assertFalse($calculation->getSuppressFormulaErrors());
|
|
$this->expectException(CalcException::class);
|
|
$this->expectExceptionMessage("Formula Error: Expecting ')'");
|
|
$result = $calculation->calculateFormula('=SUM(');
|
|
self::assertFalse($result);
|
|
}
|
|
}
|