Failed Conditions
Push — master ( ea97af...216db0 )
by
unknown
15:51 queued 07:40
created

IndirectMissingCellTest::testIssue4330()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 41
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 31
dl 0
loc 41
rs 9.424
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
class IndirectMissingCellTest extends AllSetupTeardown
8
{
9
    public function testIssue4330(): void
10
    {
11
        $sheet = $this->getSheet();
12
        $sheet->getCell('A1')->setValue(5); // used in INDIRECT
13
        $sheet->getCell('A2')->setValue(1);
14
15
        $sheet->getCell('B1')->setValue(2);
16
        $sheet->getCell('B2')->setValue(4);
17
        $sheet->getCell('B3')->setValue(6);
18
        $sheet->getCell('B4')->setValue(8);
19
        $sheet->getCell('B5')->setValue(10);
20
        $sheet->getCell('B6')->setValue(12);
21
        $sheet->getCell('C1')->setValue('=SUM(B1:INDIRECT("B"&A1))');
22
        self::assertSame(
23
            30,
24
            $sheet->getCell('C1')->getCalculatedValue(),
25
            'end cell initialized'
26
        );
27
28
        $sheet->getCell('D1')->setValue(30);
29
        $sheet->getCell('D2')->setValue(60);
30
        $sheet->getCell('D3')->setValue(90);
31
        $sheet->getCell('D4')->setValue(120);
32
        $sheet->getCell('E1')->setValue('=SUM(D1:INDIRECT("D"&A1))');
33
        self::assertSame(
34
            300,
35
            $sheet->getCell('E1')->getCalculatedValue(),
36
            'end cell not initialized'
37
        );
38
39
        //$sheet->getCell('F1')->setValue(30);
40
        //$sheet->getCell('F2')->setValue(60);
41
        $sheet->getCell('F3')->setValue(90);
42
        $sheet->getCell('F4')->setValue(120);
43
        $sheet->getCell('G1')->setValue(
44
            '=SUM(INDIRECT("F"&A2&":F"&A1))'
45
        );
46
        self::assertSame(
47
            210,
48
            $sheet->getCell('G1')->getCalculatedValue(),
49
            'range with uninitialized cells as INDIRECT argument'
50
        );
51
    }
52
}
53