Passed
Pull Request — master (#4140)
by Owen
14:24
created

Pr607Test   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 43
c 1
b 0
f 0
dl 0
loc 58
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSumData() 0 53 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xls;
6
7
use PhpOffice\PhpSpreadsheet\Cell\Cell;
8
use PhpOffice\PhpSpreadsheet\Reader\Xls as XlsReader;
9
use PHPUnit\Framework\TestCase;
10
11
class Pr607Test extends TestCase
12
{
13
    /**
14
     * Test file with cell range expressed in unexpected manner.
15
     */
16
    public static function testSumData(): void
17
    {
18
        $filename = 'tests/data/Reader/XLS/pr607.sum_data.xls';
19
        $reader = new XlsReader();
20
        $spreadsheet = $reader->load($filename);
21
22
        $tests = [
23
            'Test' => [
24
                'A1' => 1,
25
                'A2' => 2,
26
                'A3' => 3,
27
                'A4' => 4,
28
                'A5' => 5,
29
                'A6' => 6,
30
                'A7' => 7,
31
                'A8' => 8,
32
                'A9' => 9,
33
                'A10' => 10,
34
35
                'B1' => 3,
36
                'B2' => 4,
37
                'B3' => 5,
38
                'B4' => 6,
39
                'B5' => 7,
40
                'B6' => 8,
41
                'B7' => 9,
42
                'B8' => 10,
43
                'B9' => 11,
44
                'B10' => 12,
45
46
                'C1' => 4,
47
                'C2' => 6,
48
                'C3' => 8,
49
                'C4' => 10,
50
                'C5' => 12,
51
                'C6' => 14,
52
                'C7' => 16,
53
                'C8' => 18,
54
                'C9' => 20,
55
                'C10' => 22,
56
            ],
57
        ];
58
59
        foreach ($tests as $sheetName => $testsForSheet) {
60
            $sheet = $spreadsheet->getSheetByName($sheetName);
61
            self::assertNotNull($sheet);
62
63
            foreach ($testsForSheet as $cellCoordinate => $result) {
64
                $calculatedValue = $sheet->getCell($cellCoordinate)->getCalculatedValue();
65
                self::assertSame($result, $calculatedValue, "cell $cellCoordinate");
66
            }
67
        }
68
        $spreadsheet->disconnectWorksheets();
69
    }
70
}
71