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

SharedFormulaeTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSharedFormulae() 0 24 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
6
7
use PhpOffice\PhpSpreadsheet\IOFactory;
8
use PHPUnit\Framework\TestCase;
9
10
class SharedFormulaeTest extends TestCase
11
{
12
    public function testSharedFormulae(): void
13
    {
14
        // Boolean functions were not handled correctly.
15
        $filename = 'tests/data/Reader/XLSX/sharedformulae.xlsx';
16
        $reader = IOFactory::createReader('Xlsx');
17
        $spreadsheet = $reader->load($filename);
18
        $sheet = $spreadsheet->getActiveSheet();
19
        $expected = [
20
            [1, '=A1+1', '=A1>3', '="x"&A1'],
21
            [2, '=A2+1', '=A2>3', '="x"&A2'],
22
            [3, '=A3+1', '=A3>3', '="x"&A3'],
23
            [4, '=A4+1', '=A4>3', '="x"&A4'],
24
            [5, '=A5+1', '=A5>3', '="x"&A5'],
25
        ];
26
        self::assertSame($expected, $sheet->toArray(null, false, false));
27
        $expected = [
28
            [1, 2, false, 'x1'],
29
            [2, 3, false, 'x2'],
30
            [3, 4, false, 'x3'],
31
            [4, 5, true, 'x4'],
32
            [5, 6, true, 'x5'],
33
        ];
34
        self::assertSame($expected, $sheet->toArray(null, true, false));
35
        $spreadsheet->disconnectWorksheets();
36
    }
37
}
38