Failed Conditions
Pull Request — master (#3261)
by Mark
15:21
created

StructuredReferenceFormulaTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testStructuredReferences() 0 10 1
A structuredReferenceProvider() 0 11 1
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
4
5
use PhpOffice\PhpSpreadsheet\IOFactory;
6
use PHPUnit\Framework\TestCase;
7
8
class StructuredReferenceFormulaTest extends TestCase
9
{
10
    /**
11
     * @dataProvider structuredReferenceProvider
12
     */
13
    public function testStructuredReferences(float $expectedValue, string $cellAddress): void
14
    {
15
        $inputFileType = 'Xlsx';
16
        $inputFileName = __DIR__ . '/../../data/Calculation/TableFormulae.xlsx';
17
18
        $reader = IOFactory::createReader($inputFileType);
19
        $spreadsheet = $reader->load($inputFileName);
20
21
        $calculatedCellValue = $spreadsheet->getActiveSheet()->getCell($cellAddress)->getCalculatedValue();
22
        self::assertEqualsWithDelta($expectedValue, $calculatedCellValue, 1.0e-14, "Failed calculation for cell {$cellAddress}");
23
    }
24
25
    public function structuredReferenceProvider(): array
26
    {
27
        return [
28
            [26.0, 'E2'],
29
            [99.0, 'E3'],
30
            [141.0, 'E4'],
31
            [49.2, 'E5'],
32
            [120.0, 'E6'],
33
            [135.0, 'E7'],
34
            [570.2, 'E8'],
35
            [3970.0, 'C8'],
36
        ];
37
    }
38
}
39