Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/CalculationErrorTest.php
T
oleibman 79fca7601c Clean Up Some Engineering Tests
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.
2025-08-03 13:48:45 -07:00

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);
}
}