Files
oleibman 3eedf9e2f0 Better Typing in Test Members
Change "mixed" declarations to more accurate types in test members; in particular, change those that would be flagged if we were to run Phpstan at level 9 (we currently run level 8). I may or may not follow up with source code (over 700 level-9 problems remain for src), but, as with strict typing, there is no reason to avoid the effort for test members.

It was necessary to update some doc blocks in src to accommodate this change. However, no executable code is touched.
2024-01-05 01:43:50 -08:00

65 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
class ChiInvRightTailTest extends AllSetupTeardown
{
/**
* @dataProvider providerCHIINV
*/
public function testCHIINV(mixed $expectedResult, mixed ...$args): void
{
$this->runTestCases('CHISQ.INV.RT', $expectedResult, ...$args);
}
public static function providerCHIINV(): array
{
return require 'tests/data/Calculation/Statistical/CHIINVRightTail.php';
}
public function invVersusDistTest(): void
{
$expectedResult = 8.383430828608;
$probability = 0.3;
$degrees = 7;
$calculation = Calculation::getInstance();
$formula = "=CHISQ.INV.RT($probability, $degrees)";
/** @var float|int|string */
$result = $calculation->_calculateFormulaValue($formula);
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-8);
$formula = "=CHISQ.DIST.RT($result, $degrees)";
$result = $calculation->_calculateFormulaValue($formula);
self::assertEqualsWithDelta($probability, $result, 1.0e-8);
}
/**
* @dataProvider providerChiInvRightTailArray
*/
public function testChiInvRightTailArray(array $expectedResult, string $probabilities, string $degrees): void
{
$calculation = Calculation::getInstance();
$formula = "=CHISQ.INV.RT({$probabilities}, {$degrees})";
$result = $calculation->_calculateFormulaValue($formula);
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
}
public static function providerChiInvRightTailArray(): array
{
return [
'row/column vectors' => [
[
[7.8061229155968075, 6.345811195521517, 100.0],
[13.266097125199911, 11.34032237742413, 24.388802783239434],
],
'{0.35, 0.5, 0.018}',
'{7; 12}',
],
];
}
}