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

57 lines
1.6 KiB
PHP
Raw Normal View History

<?php
require_once 'testDataFileIterator.php';
class CodePageTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
2012-06-24 21:33:33 +00:00
if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
2015-05-17 13:00:02 +00:00
}
/**
* @dataProvider providerCodePage
*/
2015-05-17 13:00:02 +00:00
public function testCodePageNumberToName()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +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()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Shared/CodePage.data');
}
public function testNumberToNameWithInvalidCodePage()
2015-05-17 13:00:02 +00:00
{
$invalidCodePage = 12345;
try {
2015-05-17 16:34:30 +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 {
2015-05-17 16:34:30 +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.');
}
}