-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3868 from oleibman/issue3866
Excel Inconsistent Handling of Empty Argument MIN/MAX/MINA/MAXA
- Loading branch information
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/PhpSpreadsheetTests/Calculation/MissingArgumentsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation; | ||
|
||
use PhpOffice\PhpSpreadsheet\Spreadsheet; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class MissingArgumentsTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider providerMissingArguments | ||
*/ | ||
public function testMissingArguments(mixed $expected, string $formula): void | ||
{ | ||
$spreadsheet = new Spreadsheet(); | ||
$sheet = $spreadsheet->getActiveSheet(); | ||
$sheet->getCell('A1')->setValue($formula); | ||
self::assertSame($expected, $sheet->getCell('A1')->getCalculatedValue()); | ||
$spreadsheet->disconnectWorksheets(); | ||
} | ||
|
||
public static function providerMissingArguments(): array | ||
{ | ||
return [ | ||
'argument missing at end' => [0, '=min(3,2,)'], | ||
'argument missing at beginning' => [0, '=mina(,3,2)'], | ||
'argument missing in middle' => [0, '=min(3,,2)'], | ||
'missing argument is not result' => [-2, '=min(3,-2,)'], | ||
'max with missing argument' => [0, '=max(-3,-2,)'], | ||
'maxa with missing argument' => [0, '=maxa(-3,-2,)'], | ||
'max with null cell' => [-2, '=max(-3,-2,Z1)'], | ||
'min with null cell' => [2, '=min(3,2,Z1)'], | ||
'product ignores null argument' => [6.0, '=product(3,2,)'], | ||
'embedded function' => [5, '=sum(3,2,min(3,2,))'], | ||
'unaffected embedded function' => [8, '=sum(3,2,max(3,2,))'], | ||
]; | ||
} | ||
} |