mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-25 01:31:26 +00:00
1e8ff9f852
* DateTimeExcel - Change Names of funcWhatever to evaluate Per discussions while MathTrig was being broken up, this would help standardize the code. This PR applies that standardization to the DateTimeExcel family of functions. The deprecation messages in DateTime.php are changed to match the style used in PR #2005. All Phpstan grandfathered errors (about 25) in DateTimeExcel are fixed and removed from baseline. A small number (about 5) of phpstan annotations in the source members in that directory are also fixed and eliminated.
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
|
|
|
|
use DateTime;
|
|
use DateTimeImmutable;
|
|
use Exception;
|
|
use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Days;
|
|
|
|
class DaysTest extends AllSetupTeardown
|
|
{
|
|
/**
|
|
* @dataProvider providerDAYS
|
|
*
|
|
* @param mixed $expectedResult
|
|
*/
|
|
public function testDAYS($expectedResult, string $formula): void
|
|
{
|
|
$this->mightHaveException($expectedResult);
|
|
$sheet = $this->sheet;
|
|
$sheet->getCell('B1')->setValue('1954-11-23');
|
|
$sheet->getCell('C1')->setValue('1954-11-30');
|
|
$sheet->getCell('A1')->setValue("=DAYS($formula)");
|
|
self::assertSame($expectedResult, $sheet->getCell('A1')->getCalculatedValue());
|
|
}
|
|
|
|
public function providerDAYS(): array
|
|
{
|
|
return require 'tests/data/Calculation/DateTime/DAYS.php';
|
|
}
|
|
|
|
public function testObject(): void
|
|
{
|
|
$obj1 = new DateTime('2000-3-31');
|
|
$obj2 = new DateTimeImmutable('2000-2-29');
|
|
self::assertSame(31, Days::evaluate($obj1, $obj2));
|
|
}
|
|
|
|
public function testNonDateObject(): void
|
|
{
|
|
$obj1 = new Exception();
|
|
$obj2 = new DateTimeImmutable('2000-2-29');
|
|
self::assertSame('#VALUE!', Days::evaluate($obj1, $obj2));
|
|
}
|
|
}
|