Passed
Pull Request — master (#4114)
by Owen
14:50
created

Issue4112Test::providerSheetNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
6
7
use PhpOffice\PhpSpreadsheet\Spreadsheet;
8
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
9
use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional;
10
11
class Issue4112Test extends AbstractFunctional
12
{
13
    /**
14
     * Problem deleting all sheets then adding one.
15
     *
16
     * @dataProvider providerSheetNumber
17
     */
18
    public function testIssue4112(?int $sheetNumber): void
0 ignored issues
show
Unused Code introduced by
The parameter $sheetNumber is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

18
    public function testIssue4112(/** @scrutinizer ignore-unused */ ?int $sheetNumber): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
    {
20
        $mySpreadsheet = new Spreadsheet();
21
        $mySpreadsheet->removeSheetByIndex(0);
22
        $worksheet = new Worksheet($mySpreadsheet, 'addedsheet');
23
        self::assertSame(-1, $mySpreadsheet->getActiveSheetIndex());
24
        $mySpreadsheet->addSheet($worksheet, 0);
25
        self::assertSame('addedsheet', $mySpreadsheet->getActiveSheet()->getTitle());
26
        $row = 1;
27
        $col = 1;
28
        $worksheet->getCell([$col, $row])->setValue('id_uti');
29
        self::assertSame('id_uti', $worksheet->getCell([$col, $row])->getValue());
30
        $mySpreadsheet->disconnectWorksheets();
31
    }
32
33
    public static function providerSheetNumber(): array
34
    {
35
        return [
36
            'problem case' => [0],
37
            'normal case' => [null],
38
            'negative 1 (as if there were no sheets)' => [-1],
39
            'diffeent negative number' => [-4],
40
            'positive number' => [4],
41
        ];
42
    }
43
}
44