PhpSpreadsheet/tests/PhpSpreadsheetTests/Shared/CodePageTest.php

52 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace PhpSpreadsheetTests\Shared;
use PhpSpreadsheet\Exception;
use PhpSpreadsheet\Shared\CodePage;
2016-03-22 14:35:50 +00:00
class CodePageTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider providerCodePage
*/
2015-05-17 13:00:02 +00:00
public function testCodePageNumberToName()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array([CodePage::class, 'numberToName'], $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function providerCodePage()
{
return require 'data/Shared/CodePage.php';
2015-05-17 13:00:02 +00:00
}
public function testNumberToNameWithInvalidCodePage()
2015-05-17 13:00:02 +00:00
{
$invalidCodePage = 12345;
try {
$result = call_user_func([CodePage::class, 'numberToName'], $invalidCodePage);
} catch (Exception $e) {
2015-05-17 13:00:02 +00:00
$this->assertEquals($e->getMessage(), 'Unknown codepage: 12345');
2015-05-17 13:00:02 +00:00
return;
}
$this->fail('An expected exception has not been raised.');
}
public function testNumberToNameWithUnsupportedCodePage()
2015-05-17 13:00:02 +00:00
{
$unsupportedCodePage = 720;
try {
$result = call_user_func([CodePage::class, 'numberToName'], $unsupportedCodePage);
} catch (Exception $e) {
2015-05-17 13:00:02 +00:00
$this->assertEquals($e->getMessage(), 'Code page 720 not supported.');
2015-05-17 13:00:02 +00:00
return;
}
$this->fail('An expected exception has not been raised.');
}
}