Passed
Push — master ( bd792e...df3a06 )
by
unknown
15:51 queued 08:04
created

TransposeOnSpreadsheetTest::testTRANSPOSE()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 16
rs 9.8333
c 1
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
6
7
use PHPUnit\Framework\Attributes\DataProvider;
8
9
class TransposeOnSpreadsheetTest extends AllSetupTeardown
10
{
11
    #[DataProvider('providerTRANSPOSE')]
12
    public function testTRANSPOSE(mixed $expectedResult, mixed $matrix): void
13
    {
14
        $sheet = $this->getSheet();
15
        $this->setArrayAsArray();
16
        if (!is_array($matrix)) {
17
            $matrix = [$matrix];
18
        }
19
        $sheet->fromArray($matrix, null, 'A1', true);
20
        $highColumn = $sheet->getHighestDataColumn();
21
        $highRow = $sheet->getHighestDataRow();
22
        $newHighColumn = $highColumn;
23
        ++$newHighColumn;
24
        $sheet->getCell("{$newHighColumn}1")
25
            ->setValue("=TRANSPOSE(A1:$highColumn$highRow)");
26
        self::assertSame($expectedResult, $sheet->getCell("{$newHighColumn}1")->getCalculatedValue());
27
    }
28
29
    public static function providerTRANSPOSE(): array
30
    {
31
        return require 'tests/data/Calculation/LookupRef/TRANSPOSE.php';
32
    }
33
}
34