MatrixHelperFunctionsTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
  3. use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Matrix;
  4. use PHPUnit\Framework\TestCase;
  5. class MatrixHelperFunctionsTest extends TestCase
  6. {
  7. /**
  8. * @dataProvider columnVectorProvider
  9. */
  10. public function testIsColumnVector(bool $expectedResult, array $array): void
  11. {
  12. $result = Matrix::isColumnVector($array);
  13. self::assertSame($expectedResult, $result);
  14. }
  15. /**
  16. * @dataProvider rowVectorProvider
  17. */
  18. public function testIsRowVector(bool $expectedResult, array $array): void
  19. {
  20. $result = Matrix::isRowVector($array);
  21. self::assertSame($expectedResult, $result);
  22. }
  23. public function columnVectorProvider(): array
  24. {
  25. return [
  26. [
  27. true,
  28. [
  29. [1], [2], [3],
  30. ],
  31. ],
  32. [
  33. false,
  34. [1, 2, 3],
  35. ],
  36. [
  37. false,
  38. [
  39. [1, 2, 3],
  40. [4, 5, 6],
  41. ],
  42. ],
  43. ];
  44. }
  45. public function rowVectorProvider(): array
  46. {
  47. return [
  48. [
  49. false,
  50. [
  51. [1], [2], [3],
  52. ],
  53. ],
  54. [
  55. true,
  56. [1, 2, 3],
  57. ],
  58. [
  59. true,
  60. [[1, 2, 3]],
  61. ],
  62. [
  63. false,
  64. [
  65. [1, 2, 3],
  66. [4, 5, 6],
  67. ],
  68. ],
  69. ];
  70. }
  71. }