|
2 | 2 |
|
3 | 3 | namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
|
4 | 4 |
|
| 5 | +use PhpOffice\PhpSpreadsheet\Calculation\Calculation; |
| 6 | + |
5 | 7 | class WorkDayTest extends AllSetupTeardown
|
6 | 8 | {
|
7 | 9 | /**
|
@@ -49,4 +51,33 @@ public function providerWORKDAY(): array
|
49 | 51 | {
|
50 | 52 | return require 'tests/data/Calculation/DateTime/WORKDAY.php';
|
51 | 53 | }
|
| 54 | + |
| 55 | + /** |
| 56 | + * @dataProvider providerWorkDayArray |
| 57 | + */ |
| 58 | + public function testWorkDayArray(array $expectedResult, string $startDate, string $endDays, ?string $holidays): void |
| 59 | + { |
| 60 | + $calculation = Calculation::getInstance(); |
| 61 | + |
| 62 | + if ($holidays === null) { |
| 63 | + $formula = "=WORKDAY({$startDate}, {$endDays})"; |
| 64 | + } else { |
| 65 | + $formula = "=WORKDAY({$startDate}, {$endDays}, {$holidays})"; |
| 66 | + } |
| 67 | + $result = $calculation->_calculateFormulaValue($formula); |
| 68 | + self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); |
| 69 | + } |
| 70 | + |
| 71 | + public function providerWorkDayArray(): array |
| 72 | + { |
| 73 | + return [ |
| 74 | + 'row vector #1' => [[[44595, 44596, 44599]], '{"2022-02-01", "2022-02-02", "2022-02-03"}', '2', null], |
| 75 | + 'column vector #1' => [[[44595], [44596], [44599]], '{"2022-02-01"; "2022-02-02"; "2022-02-03"}', '2', null], |
| 76 | + 'matrix #1' => [[[44595, 44596], [44599, 44600]], '{"2022-02-01", "2022-02-02"; "2022-02-03", "2022-02-04"}', '2', null], |
| 77 | + 'row vector #2' => [[[44595, 44596]], '"2022-02-01"', '{2, 3}', null], |
| 78 | + 'column vector #2' => [[[44595], [44596]], '"2022-02-01"', '{2; 3}', null], |
| 79 | + 'row vector with Holiday' => [[[44596, 44599]], '"2022-02-01"', '{2, 3}', '{"2022-02-02"}'], |
| 80 | + 'row vector with Holidays' => [[[44599, 44600]], '"2022-02-01"', '{2, 3}', '{"2022-02-02", "2022-02-03"}'], |
| 81 | + ]; |
| 82 | + } |
52 | 83 | }
|
0 commit comments