-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
WeekNumTest.php
48 lines (40 loc) · 1.29 KB
/
WeekNumTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class WeekNumTest extends TestCase
{
private $excelCalendar;
protected function setUp(): void
{
$this->excelCalendar = Date::getExcelCalendar();
}
protected function tearDown(): void
{
Date::setExcelCalendar($this->excelCalendar);
}
/**
* @dataProvider providerWEEKNUM
*
* @param mixed $expectedResult
*/
public function testWEEKNUM($expectedResult, ...$args): void
{
$result = DateTime::WEEKNUM(...$args);
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
}
public function providerWEEKNUM()
{
return require 'tests/data/Calculation/DateTime/WEEKNUM.php';
}
public function testWEEKNUMwith1904Calendar(): void
{
Date::setExcelCalendar(Date::CALENDAR_MAC_1904);
self::assertEquals(27, DateTime::WEEKNUM('2004-07-02'));
self::assertEquals(1, DateTime::WEEKNUM('1904-01-02'));
self::assertEquals(1, DateTime::WEEKNUM(null));
// The following is a bug in Excel.
self::assertEquals(0, DateTime::WEEKNUM('1904-01-01'));
}
}