mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 16:19:19 +00:00
ec4098c8fd
While we might never be able to have 100% of our code strict, we can at the very least do it for all of our tests. This ensures that our tests are using our API with the types as intended by the test author, and not silently be cast to what our API requires.
45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Shared\Trend;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Shared\Trend\ExponentialBestFit;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ExponentialBestFitTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider providerExponentialBestFit
|
|
*/
|
|
public function testExponentialBestFit(
|
|
mixed $expectedSlope,
|
|
mixed $expectedIntersect,
|
|
mixed $expectedGoodnessOfFit,
|
|
mixed $expectedEquation,
|
|
mixed $yValues,
|
|
mixed $xValues
|
|
): void {
|
|
$bestFit = new ExponentialBestFit($yValues, $xValues);
|
|
$slope = $bestFit->getSlope(1);
|
|
self::assertEquals($expectedSlope[0], $slope);
|
|
$slope = $bestFit->getSlope();
|
|
self::assertEquals($expectedSlope[1], $slope);
|
|
$intersect = $bestFit->getIntersect(1);
|
|
self::assertEquals($expectedIntersect[0], $intersect);
|
|
$intersect = $bestFit->getIntersect();
|
|
self::assertEquals($expectedIntersect[1], $intersect);
|
|
|
|
$equation = $bestFit->getEquation(2);
|
|
self::assertEquals($expectedEquation, $equation);
|
|
|
|
self::assertSame($expectedGoodnessOfFit[0], $bestFit->getGoodnessOfFit(6));
|
|
self::assertSame($expectedGoodnessOfFit[1], $bestFit->getGoodnessOfFit());
|
|
}
|
|
|
|
public static function providerExponentialBestFit(): array
|
|
{
|
|
return require 'tests/data/Shared/Trend/ExponentialBestFit.php';
|
|
}
|
|
}
|