PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php

34 lines
968 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 CosTest extends TestCase
{
/**
* @dataProvider providerCos
*
* @param mixed $expectedResult
*/
public function testCos($expectedResult, string $formula): void
{
if ($expectedResult === 'exception') {
$this->expectException(CalcExp::class);
}
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A2', 2);
$sheet->getCell('A1')->setValue("=COS($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEqualsWithDelta($expectedResult, $result, 1E-6);
}
public function providerCos()
{
return require 'tests/data/Calculation/MathTrig/COS.php';
}
}