Failed Conditions
Push — develop ( eb5856...11b055 )
by Adrien
31:22
created

XlsTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 92 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 23
loc 25
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testFreezePane() 23 23 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Reader;
4
5
use PhpOffice\PhpSpreadsheet\Reader\Xls as ReaderXls;
6
use PhpOffice\PhpSpreadsheet\Shared\File;
7
use PhpOffice\PhpSpreadsheet\Spreadsheet;
8
use PhpOffice\PhpSpreadsheet\Writer\Xls as WriterXls;
9
use PHPUnit_Framework_TestCase;
10
11
class XlsTest extends PHPUnit_Framework_TestCase
12
{
13 View Code Duplication
    public function testFreezePane()
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...
14
    {
15
        $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet');
16
17
        $cellSplit = 'B2';
18
        $topLeftCell = 'E5';
19
20
        $spreadsheet = new Spreadsheet();
21
        $active = $spreadsheet->getActiveSheet();
22
        $active->freezePane($cellSplit, $topLeftCell);
23
24
        $writer = new WriterXls($spreadsheet);
25
        $writer->save($filename);
26
27
        // Read written file
28
        $reader = new ReaderXls();
29
        $reloadedSpreadsheet = $reader->load($filename);
30
        $reloadedActive = $reloadedSpreadsheet->getActiveSheet();
31
        $actualCellSplit = $reloadedActive->getFreezePane();
32
        $actualTopLeftCell = $reloadedActive->getTopLeftCell();
33
34
        self::assertSame($cellSplit, $actualCellSplit, 'should be able to set freeze pane');
35
        self::assertSame($topLeftCell, $actualTopLeftCell, 'should be able to set the top left cell');
36
    }
37
}
38