37 lines
1018 B
PHP
37 lines
1018 B
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalcExp;
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class CoshTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider providerCosh
|
|
*
|
|
* @param mixed $expectedResult
|
|
* @param mixed $val
|
|
*/
|
|
public function testCosh($expectedResult, $val = null): void
|
|
{
|
|
if ($val === null) {
|
|
$this->expectException(CalcExp::class);
|
|
$formula = '=COSH()';
|
|
} else {
|
|
$formula = "=COSH($val)";
|
|
}
|
|
$spreadsheet = new Spreadsheet();
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$sheet->getCell('A1')->setValue($formula);
|
|
$result = $sheet->getCell('A1')->getCalculatedValue();
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1E-6);
|
|
}
|
|
|
|
public function providerCosh()
|
|
{
|
|
return require 'tests/data/Calculation/MathTrig/COSH.php';
|
|
}
|
|
}
|