Passed
Pull Request — master (#4247)
by Owen
13:35
created

ReferenceHelper5Test   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 24
c 1
b 0
f 0
dl 0
loc 34
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testIssue4246() 0 32 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpOffice\PhpSpreadsheetTests;
6
7
use PhpOffice\PhpSpreadsheet\Spreadsheet;
8
use PHPUnit\Framework\TestCase;
9
10
class ReferenceHelper5Test extends TestCase
11
{
12
    public function testIssue4246(): void
13
    {
14
        // code below would have thrown exception because
15
        // row and column were swapped in code
16
        $spreadsheet = new Spreadsheet();
17
        $sheet = $spreadsheet->getActiveSheet();
18
        $row = 987654;
19
        $rowMinus1 = $row - 1;
20
        $rowPlus1 = $row + 1;
21
        $sheet->getCell("A$rowMinus1")->setValue(1);
22
        $sheet->getCell("B$rowMinus1")->setValue(2);
23
        $sheet->getCell("C$rowMinus1")->setValue(3);
24
        $sheet->getStyle("A$rowMinus1")->getFont()->setBold(true);
25
        $sheet->getCell("A$row")->setValue(1);
26
        $sheet->getCell("B$row")->setValue(2);
27
        $sheet->getCell("C$row")->setValue(3);
28
        $sheet->getStyle("B$row")->getFont()->setBold(true);
29
30
        $sheet->insertNewRowBefore($row);
31
        self::assertTrue(
32
            $sheet->getStyle("A$row")->getFont()->getBold()
33
        );
34
        self::assertFalse(
35
            $sheet->getStyle("B$row")->getFont()->getBold()
36
        );
37
        self::assertFalse(
38
            $sheet->getStyle("A$rowPlus1")->getFont()->getBold()
39
        );
40
        self::assertTrue(
41
            $sheet->getStyle("B$rowPlus1")->getFont()->getBold()
42
        );
43
        $spreadsheet->disconnectWorksheets();
44
    }
45
}
46