0.999999 && $frac < 1.000001) { $result = $expectedResult; } } } self::assertEquals($expectedResult, $result, $message); } public function providerXIRR() { return require 'tests/data/Calculation/Financial/XIRR.php'; } /** * @dataProvider providerXNPV * * @param mixed $expectedResult * @param mixed $message */ public function testXNPV($expectedResult, $message, ...$args) { $result = Financial::XNPV(...$args); if (is_numeric($result) && is_numeric($expectedResult)) { if ($expectedResult != 0) { $frac = $result / $expectedResult; if ($frac > 0.999999 && $frac < 1.000001) { $result = $expectedResult; } } } self::assertEquals($expectedResult, $result, $message); } public function providerXNPV() { return require 'data/Calculation/Financial/XNPV.php'; } /** * @dataProvider providerPDURATION * * @param mixed $expectedResult */ public function testPDURATION($expectedResult, array $args) { $result = Financial::PDURATION(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerPDURATION() { return require 'tests/data/Calculation/Financial/PDURATION.php'; } /** * @dataProvider providerRRI * * @param mixed $expectedResult */ public function testRRI($expectedResult, array $args) { $result = Financial::RRI(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerRRI() { return require 'tests/data/Calculation/Financial/RRI.php'; } /** * @dataProvider providerSLN * * @param mixed $expectedResult */ public function testSLN($expectedResult, array $args) { $result = Financial::SLN(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerSLN() { return require 'tests/data/Calculation/Financial/SLN.php'; } /** * @dataProvider providerSYD * * @param mixed $expectedResult */ public function testSYD($expectedResult, array $args) { $result = Financial::SYD(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerSYD() { return require 'tests/data/Calculation/Financial/SYD.php'; } }