IfTest.php 909 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Logical;
  4. use PHPUnit\Framework\TestCase;
  5. class IfTest extends TestCase
  6. {
  7. /**
  8. * @dataProvider providerIF
  9. *
  10. * @param mixed $expectedResult
  11. */
  12. public function testIF($expectedResult, ...$args): void
  13. {
  14. if (count($args) === 0) {
  15. $result = Logical::statementIf();
  16. } elseif (count($args) === 1) {
  17. $result = Logical::statementIf($args[0]);
  18. } elseif (count($args) === 2) {
  19. $result = Logical::statementIf($args[0], $args[1]);
  20. } else {
  21. $result = Logical::statementIf($args[0], $args[1], $args[2]);
  22. }
  23. self::assertEquals($expectedResult, $result);
  24. }
  25. public function providerIF(): array
  26. {
  27. return require 'tests/data/Calculation/Logical/IF.php';
  28. }
  29. }