Passed
Pull Request — master (#4286)
by Owen
14:54
created

ExpandTest::providerExpand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
6
7
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
8
use PhpOffice\PhpSpreadsheet\NamedRange;
9
use PHPUnit\Framework\Attributes\DataProvider;
10
11
class ExpandTest extends AllSetupTeardown
12
{
13
    #[DataProvider('providerExpand')]
14
    public function testExpand(mixed $expectedResult, string $formula): void
15
    {
16
        Calculation::setArrayReturnType(
17
            Calculation::RETURN_ARRAY_AS_ARRAY
18
        );
19
        $this->mightHaveException($expectedResult);
20
        $sheet = $this->getSheet();
21
        $sheet->fromArray(
22
            [
23
                ['a', 'b', 'c'],
24
                ['d', 'e', 'f'],
25
            ],
26
            null,
27
            'B3',
28
            true
29
        );
30
        $this->getSpreadsheet()->addNamedRange(
31
            new NamedRange(
32
                'definedname',
33
                $sheet,
34
                '$B$3:$D$11'
35
            )
36
        );
37
38
        $sheet->setCellValue('F3', $formula);
39
        $result = $sheet->getCell('F3')->getCalculatedValue();
40
        self::assertSame($expectedResult, $result);
41
    }
42
43
    public static function providerExpand(): array
44
    {
45
        return require 'tests/data/Calculation/LookupRef/EXPAND.php';
46
    }
47
}
48