mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-27 18:48:36 +00:00
1b05dfab8b
And quite a bit more manual changes. The idea is that typing of our tests can be a bit more loose, so we assume PHPDoc is mostly correct. If that happens to be wrong, it should be caught by the tests themselves.
48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
|
|
|
class CosTest extends AllSetupTeardown
|
|
{
|
|
/**
|
|
* @dataProvider providerCos
|
|
*/
|
|
public function testCos(mixed $expectedResult, string $formula): void
|
|
{
|
|
$this->mightHaveException($expectedResult);
|
|
$sheet = $this->getSheet();
|
|
$sheet->setCellValue('A2', 2);
|
|
$sheet->getCell('A1')->setValue("=COS($formula)");
|
|
$result = $sheet->getCell('A1')->getCalculatedValue();
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1E-6);
|
|
}
|
|
|
|
public static function providerCos(): array
|
|
{
|
|
return require 'tests/data/Calculation/MathTrig/COS.php';
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerCosArray
|
|
*/
|
|
public function testCosArray(array $expectedResult, string $array): void
|
|
{
|
|
$calculation = Calculation::getInstance();
|
|
|
|
$formula = "=COS({$array})";
|
|
$result = $calculation->_calculateFormulaValue($formula);
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
|
}
|
|
|
|
public static function providerCosArray(): array
|
|
{
|
|
return [
|
|
'row vector' => [[[0.54030230586814, 0.87758256189037, 0.54030230586814]], '{1, 0.5, -1}'],
|
|
'column vector' => [[[0.54030230586814], [0.87758256189037], [0.54030230586814]], '{1; 0.5; -1}'],
|
|
'matrix' => [[[0.54030230586814, 0.87758256189037], [1.0, 0.54030230586814]], '{1, 0.5; 0, -1}'],
|
|
];
|
|
}
|
|
}
|