Additional unit tests for previously untested financial functions (#1815)
* Additional unit tests for previously untested financial functions, and some additions to follow untested paths * Start splitting Financial function tests out from the large FinancialTests class into individual test classes for each function
This commit is contained in:
parent
80155cf26a
commit
41c8a4f1b4
|
|
@ -2037,7 +2037,7 @@ class Financial
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
++$maturity;
|
||||
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity) * 360;
|
||||
} else {
|
||||
|
|
@ -2076,7 +2076,7 @@ class Financial
|
|||
return Functions::NAN();
|
||||
}
|
||||
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
++$maturity;
|
||||
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity) * 360;
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
|
|
@ -2087,7 +2087,7 @@ class Financial
|
|||
$daysBetweenSettlementAndMaturity = (DateTime::getDateValue($maturity) - DateTime::getDateValue($settlement));
|
||||
}
|
||||
|
||||
if ($daysBetweenSettlementAndMaturity > 360) {
|
||||
if ($daysBetweenSettlementAndMaturity > self::daysPerYear(DateTime::YEAR($maturity), 1)) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,134 +13,6 @@ class FinancialTest extends TestCase
|
|||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAMORDEGRC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testAMORDEGRC($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::AMORDEGRC(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerAMORDEGRC()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/AMORDEGRC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAMORLINC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testAMORLINC($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::AMORLINC(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerAMORLINC()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/AMORLINC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPDAYBS
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPDAYBS($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPDAYBS(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPDAYBS()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPDAYBS.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPDAYS
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPDAYS($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPDAYS(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPDAYS()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPDAYS.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPDAYSNC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPDAYSNC($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPDAYSNC(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPDAYSNC()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPDAYSNC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPNCD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPNCD($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPNCD(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPNCD()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPNCD.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPNUM
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPNUM($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPNUM(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPNUM()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPNUM.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPPCD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPPCD($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPPCD(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPPCD()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPPCD.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCUMIPMT
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AmorDegRcTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAMORDEGRC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testAMORDEGRC($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::AMORDEGRC(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerAMORDEGRC()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/AMORDEGRC.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AmorLincTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAMORLINC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testAMORLINC($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::AMORLINC(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerAMORLINC()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/AMORLINC.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoupDayBsTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPDAYBS
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPDAYBS($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPDAYBS(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPDAYBS()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPDAYBS.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoupDaysNcTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPDAYSNC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPDAYSNC($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPDAYSNC(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPDAYSNC()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPDAYSNC.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoupDaysTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPDAYS
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPDAYS($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPDAYS(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPDAYS()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPDAYS.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoupNcdTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPNCD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPNCD($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPNCD(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPNCD()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPNCD.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoupNumTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPNUM
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPNUM($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPNUM(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPNUM()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPNUM.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoupPcdTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPPCD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPPCD($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::COUPPCD(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPPCD()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/COUPPCD.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PriceMatTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerPRICEMAT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testPRICEMAT($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::PRICEMAT(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerPRICEMAT()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/PRICEMAT.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ReceivedTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerRECEIVED
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testRECEIVED($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::RECEIVED(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerRECEIVED()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/RECEIVED.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TBillEqTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTBILLEQ
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testTBILLEQ($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::TBILLEQ(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerTBILLEQ()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/TBILLEQ.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TBillPriceTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTBILLPRICE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testTBILLPRICE($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::TBILLPRICE(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerTBILLPRICE()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/TBILLPRICE.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TBillYieldTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTBILLYIELD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testTBILLYIELD($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::TBILLYIELD(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerTBILLYIELD()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/TBILLYIELD.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class YieldDiscTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerYIELDDISC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testYIELDDISC($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::YIELDDISC(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerYIELDDISC()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/YIELDDISC.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class YieldMatTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerYIELDMAT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testYIELDMAT($expectedResult, ...$args): void
|
||||
{
|
||||
$result = Financial::YIELDMAT(...$args);
|
||||
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
||||
}
|
||||
|
||||
public function providerYIELDMAT()
|
||||
{
|
||||
return require 'tests/data/Calculation/Financial/YIELDMAT.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -5,22 +5,22 @@
|
|||
return [
|
||||
[
|
||||
776,
|
||||
2400,
|
||||
'2008-08-19',
|
||||
'2008-12-31',
|
||||
300,
|
||||
1,
|
||||
0.14999999999999999,
|
||||
1,
|
||||
2400, '2008-08-19', '2008-12-31', 300, 1, 0.15, 1,
|
||||
],
|
||||
[
|
||||
42,
|
||||
150,
|
||||
'2011-01-01',
|
||||
'2011-09-30',
|
||||
20,
|
||||
1,
|
||||
0.20000000000000001,
|
||||
4,
|
||||
150, '2011-01-01', '2011-09-30', 20, 1, 0.2, 4,
|
||||
],
|
||||
[
|
||||
25,
|
||||
150, '2011-01-01', '2011-09-30', 20, 2, 0.2, 4,
|
||||
],
|
||||
[
|
||||
16,
|
||||
150, '2011-01-01', '2011-09-30', 20, 3, 0.15, 4,
|
||||
],
|
||||
[
|
||||
42,
|
||||
150, '2011-01-01', '2011-09-30', 20, 1, 0.4, 4,
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,22 +5,22 @@
|
|||
return [
|
||||
[
|
||||
360,
|
||||
2400,
|
||||
'2008-08-19',
|
||||
'2008-12-31',
|
||||
300,
|
||||
1,
|
||||
0.14999999999999999,
|
||||
1,
|
||||
2400, '2008-08-19', '2008-12-31', 300, 1, 0.14999999999999999, 1,
|
||||
],
|
||||
[
|
||||
30,
|
||||
150,
|
||||
'2011-01-01',
|
||||
'2011-09-30',
|
||||
20,
|
||||
1,
|
||||
0.20000000000000001,
|
||||
4,
|
||||
150, '2011-01-01', '2011-09-30', 20, 1, 0.20000000000000001, 4,
|
||||
],
|
||||
[
|
||||
22.41666667,
|
||||
150, '2011-01-01', '2011-09-30', 20, 0, 0.20000000000000001, 4,
|
||||
],
|
||||
[
|
||||
17.58333333,
|
||||
150, '2011-01-01', '2011-09-30', 20, 4, 0.20000000000000001, 4,
|
||||
],
|
||||
[
|
||||
0.0,
|
||||
150, '2011-01-01', '2011-09-30', 20, 5, 0.20000000000000001, 4,
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
99.98449887555694,
|
||||
'15-Feb-2008', '13-Apr-2008', '11-Nov-2007', 0.061, 0.061, 0,
|
||||
],
|
||||
[
|
||||
106.8486842105263,
|
||||
'1-Apr-2017', '31-Mar-2021', '1-Jan-2017', 0.055, 0.035,
|
||||
],
|
||||
[
|
||||
93.0909090909091,
|
||||
'1-Jul-2017', '1-Jan-2027', '1-Jan-2017', 0.07, 0.08,
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
1014584.6544071021,
|
||||
'15-Feb-2008', '15-May-2008', 1000000, 0.0575, 2,
|
||||
],
|
||||
[
|
||||
1120.2128404396835,
|
||||
'6-Jul-2017', '15-Jan-2020', 1000, 0.0425,
|
||||
],
|
||||
[
|
||||
273037.54266211606,
|
||||
'15-Feb-2008', '15-Nov-2017', 100000, 0.065,
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
0.09415149356594302,
|
||||
'31-Mar-2008', '1-Jun-2008', 0.0914,
|
||||
],
|
||||
[
|
||||
0.025465926064094112,
|
||||
'5-Feb-2019', '1-Feb-2020', 0.0245,
|
||||
],
|
||||
[
|
||||
0.036787997465875716,
|
||||
'1-Feb-2016', '30-Jan-2017', 0.035,
|
||||
],
|
||||
[
|
||||
0.025612238,
|
||||
'1-Feb-2017', '30-Jun-2017', 0.025,
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
98.45,
|
||||
'31-Mar-2008', '1-Jun-2008', 0.09,
|
||||
],
|
||||
[
|
||||
97.75,
|
||||
'1-Apr-2017', '30-Jun-2017', 0.09,
|
||||
],
|
||||
[
|
||||
97.54319444444445,
|
||||
'5-Feb-2019', '1-Feb-2020', 0.0245,
|
||||
],
|
||||
[
|
||||
98.86180556,
|
||||
'1-Feb-2017', '30-Jun-2017', 0.0275,
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
0.09141696292534264,
|
||||
'31-Mar-2008', '1-Jun-2008', 98.45,
|
||||
],
|
||||
[
|
||||
0.024405125076266018,
|
||||
'1-Feb-2017', '30-Jun-2017', 99,
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
0.05282257198685834,
|
||||
'16-Feb-2008', '1-Mar-2008', 99.795, 100, 2,
|
||||
],
|
||||
[
|
||||
0.06220123250590336,
|
||||
'1-Jan-2017', '30-Jun-2017', 97, 100,
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
0.06095433369153867,
|
||||
'15-Mar-2008', '3-Nov-2008', '8-Nov-2007', 0.0625, 100.0123, 0,
|
||||
],
|
||||
[
|
||||
0.04210977320221025,
|
||||
'1-Jan-2017', '30-Jun-2018', '01-Jul-2014', 0.055, 101,
|
||||
],
|
||||
];
|
||||
Loading…
Reference in New Issue