Passed
Push — master ( 5f7ed9...f1e82a )
by Mark
28:04
created

CodePageTest::testCodePageNumberToName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Shared;
4
5
use PhpOffice\PhpSpreadsheet\Exception;
6
use PhpOffice\PhpSpreadsheet\Shared\CodePage;
7
use PHPUnit\Framework\TestCase;
8
9
class CodePageTest extends TestCase
10
{
11
    /**
12
     * @dataProvider providerCodePage
13
     *
14
     * @param mixed $expectedResult
15
     */
16
    public function testCodePageNumberToName($expectedResult, ...$args)
17
    {
18
        $result = CodePage::numberToName(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $codePage of PhpOffice\PhpSpreadsheet...odePage::numberToName() does not expect variable arguments. ( Ignorable by Annotation )

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

18
        $result = CodePage::numberToName(/** @scrutinizer ignore-type */ ...$args);
Loading history...
19
        self::assertEquals($expectedResult, $result);
20
    }
21
22
    public function providerCodePage()
23
    {
24
        return require 'data/Shared/CodePage.php';
25
    }
26
27
    public function testNumberToNameWithInvalidCodePage()
28
    {
29
        $invalidCodePage = 12345;
30
31
        try {
32
            CodePage::numberToName($invalidCodePage);
33
        } catch (Exception $e) {
34
            self::assertEquals($e->getMessage(), 'Unknown codepage: 12345');
35
36
            return;
37
        }
38
        $this->fail('An expected exception has not been raised.');
39
    }
40
41
    public function testNumberToNameWithUnsupportedCodePage()
42
    {
43
        $unsupportedCodePage = 720;
44
45
        try {
46
            CodePage::numberToName($unsupportedCodePage);
47
        } catch (Exception $e) {
48
            self::assertEquals($e->getMessage(), 'Code page 720 not supported.');
49
50
            return;
51
        }
52
        $this->fail('An expected exception has not been raised.');
53
    }
54
}
55