Failed Conditions
Push — develop ( 11b055...32a55a )
by Adrien
30:13
created

MergedCells::testMergedCells()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 1
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Functional;
4
5
use PhpOffice\PhpSpreadsheet\Spreadsheet;
6
7
class MergedCells extends AbstractFunctional
8
{
9 View Code Duplication
    public function providerFormats()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
    {
11
        return [
12
            ['Html'],
13
            ['Xls'],
14
            ['Xlsx'],
15
            ['Ods'],
16
        ];
17
    }
18
19
    /**
20
     * @dataProvider providerFormats
21
     *
22
     * @param string $format
23
     */
24
    public function testMergedCells($format)
25
    {
26
        $spreadsheet = new Spreadsheet();
27
        $spreadsheet->setActiveSheetIndex(0);
28
        $spreadsheet->getActiveSheet()->setCellValue('A1', '1');
29
        $spreadsheet->getActiveSheet()->setCellValue('B1', '2');
30
        $spreadsheet->getActiveSheet()->setCellValue('A2', '33');
31
        $spreadsheet->getActiveSheet()->mergeCells('A2:B2');
32
33
        $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
34
35
        $actual = 0;
36
        foreach ($reloadedSpreadsheet->getWorksheetIterator() as $worksheet) {
37
            $actual += count($worksheet->getMergeCells());
38
        }
39
40
        self::assertSame(1, $actual, "Format $format failed, could not read 1 merged cell");
41
    }
42
}
43