mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-26 16:28:28 +00:00
5d309e982c
* Extract remaining Financial function unit tests into separate test classes for each function This makes it easier to manage unit tests if they are individual files rather than all in a single file It also provides a stepping stone toward making it easier to test Excel functions when Excel errors no longer return a string, but an actual Excel exception that can be handled more cleanly
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class PriceTest extends TestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerPRICE
|
|
*
|
|
* @param mixed $expectedResult
|
|
*/
|
|
public function testPRICE($expectedResult, ...$args): void
|
|
{
|
|
$result = Financial::PRICE(...$args);
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1E-7);
|
|
}
|
|
|
|
public function providerPRICE()
|
|
{
|
|
return require 'tests/data/Calculation/Financial/PRICE.php';
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerPRICE3
|
|
*
|
|
* @param mixed $expectedResult
|
|
*/
|
|
public function testPRICE3($expectedResult, ...$args): void
|
|
{
|
|
// These results (PRICE function with basis codes 2 and 3)
|
|
// agree with published algorithm, LibreOffice, and Gnumeric.
|
|
// They do not agree with Excel.
|
|
$result = Financial::PRICE(...$args);
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1E-7);
|
|
}
|
|
|
|
public function providerPRICE3()
|
|
{
|
|
return require 'tests/data/Calculation/Financial/PRICE3.php';
|
|
}
|
|
}
|