PhpSpreadsheet/unitTests/Classes/src/Shared/CodePageTest.php

49 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2016-03-22 14:35:50 +00:00
namespace PHPExcel\Shared;
require_once 'testDataFileIterator.php';
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);
2016-03-22 21:40:11 +00:00
$result = call_user_func_array(array('\PHPExcel\Shared\CodePage','numberToName'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function providerCodePage()
{
2016-03-22 14:35:50 +00:00
return new \testDataFileIterator('rawTestData/Shared/CodePage.data');
2015-05-17 13:00:02 +00:00
}
public function testNumberToNameWithInvalidCodePage()
2015-05-17 13:00:02 +00:00
{
$invalidCodePage = 12345;
try {
2016-03-22 21:40:11 +00:00
$result = call_user_func(array('\PHPExcel\Shared\CodePage','numberToName'), $invalidCodePage);
2015-05-17 13:00:02 +00:00
} catch (Exception $e) {
$this->assertEquals($e->getMessage(), 'Unknown codepage: 12345');
return;
}
$this->fail('An expected exception has not been raised.');
}
public function testNumberToNameWithUnsupportedCodePage()
2015-05-17 13:00:02 +00:00
{
$unsupportedCodePage = 720;
try {
2016-03-22 21:40:11 +00:00
$result = call_user_func(array('\PHPExcel\Shared\CodePage','numberToName'), $unsupportedCodePage);
2015-05-17 13:00:02 +00:00
} catch (Exception $e) {
$this->assertEquals($e->getMessage(), 'Code page 720 not supported.');
return;
}
$this->fail('An expected exception has not been raised.');
}
}