mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-14 03:56:40 +00:00
e9cf27354d
Successor to PR #3523. There are 494 single-line changes (`public function provider` to `public static function provider`) in this PR. None of these were made manually; they were all created with the following script (adapted from https://stackoverflow.com/questions/25909820/how-to-recursively-iterate-through-files-in-php): ```php $dir = 'C:/git/unit10prep2/tests/PhpSpreadsheetTests'; $it = new RecursiveDirectoryIterator($dir); // Loop through files foreach(new RecursiveIteratorIterator($it) as $file) { if ($file->getExtension() === 'php') { $contents = file_get_contents($file); $new = preg_replace('/public function (\\w*)([Pp])rovider/', 'public static function $1$2rovider', $contents); if ($new !== $contents) { echo "changing $file\n"; file_put_contents($file, $new); } } } ``` After this PR, there will be one more, with a small number of test changes, and enabling PhpUnit 10 for Php 8.1+.
72 lines
2.1 KiB
PHP
72 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
|
|
|
class DollarDeTest extends AllSetupTeardown
|
|
{
|
|
/**
|
|
* @dataProvider providerDOLLARDE
|
|
*
|
|
* @param mixed $expectedResult
|
|
*/
|
|
public function testDOLLARDE($expectedResult, ...$args): void
|
|
{
|
|
$this->runTestCase('DOLLARDE', $expectedResult, $args);
|
|
}
|
|
|
|
public static function providerDOLLARDE(): array
|
|
{
|
|
return require 'tests/data/Calculation/Financial/DOLLARDE.php';
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerDollarDeArray
|
|
*/
|
|
public function testDollarDeArray(array $expectedResult, string $argument1, string $argument2): void
|
|
{
|
|
$calculation = Calculation::getInstance();
|
|
|
|
$formula = "=DollarDe({$argument1},{$argument2})";
|
|
$result = $calculation->_calculateFormulaValue($formula);
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12);
|
|
}
|
|
|
|
public static function providerDollarDeArray(): array
|
|
{
|
|
return [
|
|
'first argument row vector' => [
|
|
[[1.125, 2.0625, -12.625, 3.5]],
|
|
'{1.02, 2.01, -12.1, 1.4}',
|
|
'16',
|
|
],
|
|
'first argument column vector' => [
|
|
[[1.0625], [2.03125], [-12.3125], [2.25]],
|
|
'{1.02; 2.01; -12.1; 1.4}',
|
|
'32',
|
|
],
|
|
'first argument matrix' => [
|
|
[[1.05, 2.25], [-12.5, 2.0]],
|
|
'{1.02, 2.1; -12.2, 1.4}',
|
|
'4',
|
|
],
|
|
'second argument row vector' => [
|
|
[[4.25, 3.625, 6.125, 4.5625]],
|
|
'3.5',
|
|
'{4, 8, 16, 32}',
|
|
],
|
|
'second argument column vector' => [
|
|
[[5.5], [4.25], [3.625], [6.125]],
|
|
'3.5',
|
|
'{2; 4; 8; 16}',
|
|
],
|
|
'second argument matrix' => [
|
|
[[-4.875, -3.9375], [-9.25, -7.6875]],
|
|
'-3.75',
|
|
'{4, 8; 12, 16}',
|
|
],
|
|
];
|
|
}
|
|
}
|