ArabicTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. class ArabicTest extends AllSetupTeardown
  5. {
  6. /**
  7. * @dataProvider providerARABIC
  8. *
  9. * @param mixed $expectedResult
  10. * @param string $romanNumeral
  11. */
  12. public function testARABIC($expectedResult, $romanNumeral): void
  13. {
  14. $this->mightHaveException($expectedResult);
  15. $sheet = $this->getSheet();
  16. $sheet->getCell('A1')->setValue($romanNumeral);
  17. $sheet->getCell('B1')->setValue('=ARABIC(A1)');
  18. $result = $sheet->getCell('B1')->getCalculatedValue();
  19. self::assertSame($expectedResult, $result);
  20. }
  21. public function providerARABIC(): array
  22. {
  23. return require 'tests/data/Calculation/MathTrig/ARABIC.php';
  24. }
  25. /**
  26. * @dataProvider providerArabicArray
  27. */
  28. public function testArabicArray(array $expectedResult, string $array): void
  29. {
  30. $calculation = Calculation::getInstance();
  31. $formula = "=ARABIC({$array})";
  32. $result = $calculation->_calculateFormulaValue($formula);
  33. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  34. }
  35. public function providerArabicArray(): array
  36. {
  37. return [
  38. 'row vector' => [[[49, 2022, 499]], '{"XLIX", "MMXXII", "VDIV"}'],
  39. 'column vector' => [[[49], [2022], [499]], '{"XLIX"; "MMXXII"; "VDIV"}'],
  40. 'matrix' => [[[49, 2022], [-499, 499]], '{"XLIX", "MMXXII"; "-ID", "VDIV"}'],
  41. ];
  42. }
  43. }