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

DropTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 28
dl 0
loc 42
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A providerDrop() 0 3 1
A testDrop() 0 35 1
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 DropTest extends AllSetupTeardown
12
{
13
    #[DataProvider('providerDrop')]
14
    public function testDrop(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
                ['g', 'h', 'i'],
26
                ['j', 'k', 'l'],
27
                ['m', 'n', 'o'],
28
                ['p', 'q', 'r'],
29
                ['s', 't', 'u'],
30
                ['v', 'w', 'x'],
31
                ['y', 'z', '#'],
32
            ],
33
            null,
34
            'B3',
35
            true
36
        );
37
        $this->getSpreadsheet()->addNamedRange(
38
            new NamedRange(
39
                'definedname',
40
                $sheet,
41
                '$B$3:$D$11'
42
            )
43
        );
44
45
        $sheet->setCellValue('F3', $formula);
46
        $result = $sheet->getCell('F3')->getCalculatedValue();
47
        self::assertSame($expectedResult, $result);
48
    }
49
50
    public static function providerDrop(): array
51
    {
52
        return require 'tests/data/Calculation/LookupRef/DROP.php';
53
    }
54
}
55