ImSumTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Engineering;
  4. use PhpOffice\PhpSpreadsheet\Calculation\Functions;
  5. use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert;
  6. use PHPUnit\Framework\TestCase;
  7. class ImSumTest extends TestCase
  8. {
  9. const COMPLEX_PRECISION = 1E-8;
  10. /**
  11. * @var ComplexAssert
  12. */
  13. private $complexAssert;
  14. protected function setUp(): void
  15. {
  16. Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
  17. $this->complexAssert = new ComplexAssert();
  18. }
  19. /**
  20. * @dataProvider providerIMSUM
  21. *
  22. * @param mixed $expectedResult
  23. */
  24. public function testIMSUM($expectedResult, ...$args): void
  25. {
  26. $result = Engineering::IMSUM(...$args);
  27. self::assertTrue(
  28. $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION),
  29. $this->complexAssert->getErrorMessage()
  30. );
  31. }
  32. public function providerIMSUM(): array
  33. {
  34. return require 'tests/data/Calculation/Engineering/IMSUM.php';
  35. }
  36. }