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
![]() |
|||
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 |