Files
oleibman a884013d00 Fix Unintential Deprecated Calls in Tests - FINANCIAL (#3180)
* Fix Unintential Deprecated Calls in Tests - FINANCIAL

I think it's best to install these before PR #3166. There are no changes to source code, only to doc-blocks and to test members which continue to inadvertently use calls to deprecated functions.

* Change Tests to Run in Spreadsheet Context

Found and fixed some problems with how MIRR handles errors.
2022-11-25 07:19:19 -08:00

43 lines
1.3 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
class FvScheduleTest extends AllSetupTeardown
{
/**
* @dataProvider providerFVSCHEDULE
*
* @param mixed $expectedResult
* @param mixed $principal
*/
public function testFVSCHEDULE($expectedResult, $principal = null, ?array $schedule = null): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->getSheet();
$formula = '=FVSCHEDULE(';
if ($principal !== null) {
$this->setCell('A1', $principal);
$formula .= 'A1';
if (!empty($schedule)) {
$row = 0;
foreach ($schedule as $value) {
++$row;
$this->setCell("B$row", $value);
}
$formula .= ",B1:B$row";
}
}
$formula .= ')';
$sheet->getCell('D1')->setValue($formula);
$result = $sheet->getCell('D1')->getCalculatedValue();
$this->adjustResult($result, $expectedResult);
self::assertEqualsWithDelta($expectedResult, $result, 1.0E-8);
}
public function providerFVSCHEDULE(): array
{
return require 'tests/data/Calculation/Financial/FVSCHEDULE.php';
}
}