Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php
T
oleibman 1e8ff9f852 DateTimeExcel - Change Names of funcWhatever to evaluate (#2015)
* 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.
2021-04-24 18:56:58 +02:00

49 lines
1.4 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\EoMonth;
class EoMonthTest extends AllSetupTeardown
{
/**
* @dataProvider providerEOMONTH
*
* @param mixed $expectedResult
*/
public function testEOMONTH($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet->getCell('A1')->setValue("=EOMONTH($formula)");
$sheet->getCell('B1')->setValue('1954-11-23');
self::assertEquals($expectedResult, $sheet->getCell('A1')->getCalculatedValue());
}
public function providerEOMONTH(): array
{
return require 'tests/data/Calculation/DateTime/EOMONTH.php';
}
public function testEOMONTHtoUnixTimestamp(): void
{
self::setUnixReturn();
$result = EoMonth::evaluate('2012-1-26', -1);
self::assertEquals(1325289600, $result);
}
public function testEOMONTHtoDateTimeObject(): void
{
self::setObjectReturn();
$result = EoMonth::evaluate('2012-1-26', -1);
// Must return an object...
self::assertIsObject($result);
// ... of the correct type
self::assertTrue(is_a($result, 'DateTimeInterface'));
// ... with the correct value
self::assertSame($result->format('d-M-Y'), '31-Dec-2011');
}
}