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

38 lines
1.1 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalcExp;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PHPUnit\Framework\TestCase;
class RoundDownTest extends TestCase
{
/**
* @dataProvider providerRoundDown
*
* @param mixed $expectedResult
* @param mixed $formula
*/
public function testRoundDown($expectedResult, $formula): void
{
if ($expectedResult === 'exception') {
$this->expectException(CalcExp::class);
}
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);
$sheet->setCellValue('A5', -5.2);
$sheet->getCell('A1')->setValue("=ROUNDDOWN($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
}
public function providerRoundDown()
{
return require 'tests/data/Calculation/MathTrig/ROUNDDOWN.php';
}
}