diff --git a/unitTests/PHPExcel/Calculation/TextDataTest.php b/unitTests/PHPExcel/Calculation/TextDataTest.php index f78f58d..50d27bb 100644 --- a/unitTests/PHPExcel/Calculation/TextDataTest.php +++ b/unitTests/PHPExcel/Calculation/TextDataTest.php @@ -324,6 +324,11 @@ class TextDataTest extends PHPUnit_Framework_TestCase */ public function testTEXT() { + // Enforce decimal and thousands separator values to UK/US, and currency code to USD + call_user_func(array('PHPExcel_Shared_String','setDecimalSeparator'),'.'); + call_user_func(array('PHPExcel_Shared_String','setThousandsSeparator'),','); + call_user_func(array('PHPExcel_Shared_String','setCurrencyCode'),'$'); + $args = func_get_args(); $expectedResult = array_pop($args); $result = call_user_func_array(array('PHPExcel_Calculation_TextData','TEXTFORMAT'),$args); diff --git a/unitTests/PHPExcel/Shared/CodePageTest.php b/unitTests/PHPExcel/Shared/CodePageTest.php new file mode 100644 index 0000000..27c00c6 --- /dev/null +++ b/unitTests/PHPExcel/Shared/CodePageTest.php @@ -0,0 +1,58 @@ +assertEquals($expectedResult, $result); + } + + public function providerCodePage() + { + return new testDataFileIterator('rawTestData/Shared/CodePage.data'); + } + + public function testNumberToNameWithInvalidCodePage() + { + $invalidCodePage = 12345; + try { + $result = call_user_func(array('PHPExcel_Shared_CodePage','NumberToName'),$invalidCodePage); + } catch (Exception $e) { + $this->assertEquals($e->getMessage(), 'Unknown codepage: 12345'); + return; + } + $this->fail('An expected exception has not been raised.'); + } + + public function testNumberToNameWithUnsupportedCodePage() + { + $unsupportedCodePage = 720; + try { + $result = call_user_func(array('PHPExcel_Shared_CodePage','NumberToName'),$unsupportedCodePage); + } catch (Exception $e) { + $this->assertEquals($e->getMessage(), 'Code page 720 not supported.'); + return; + } + $this->fail('An expected exception has not been raised.'); + } + +} diff --git a/unitTests/PHPExcel/Shared/StringTest.php b/unitTests/PHPExcel/Shared/StringTest.php new file mode 100644 index 0000000..ad32b8b --- /dev/null +++ b/unitTests/PHPExcel/Shared/StringTest.php @@ -0,0 +1,84 @@ +assertTrue($result); + } + + public function testGetIsIconvEnabled() + { + $result = call_user_func(array('PHPExcel_Shared_String','getIsIconvEnabled')); + $this->assertTrue($result); + } + + public function testGetDecimalSeparator() + { + $localeconv = localeconv(); + + $expectedResult = (!empty($localeconv['decimal_point'])) ? $localeconv['decimal_point'] : ','; + $result = call_user_func(array('PHPExcel_Shared_String','getDecimalSeparator')); + $this->assertEquals($expectedResult, $result); + } + + public function testSetDecimalSeparator() + { + $expectedResult = ','; + $result = call_user_func(array('PHPExcel_Shared_String','setDecimalSeparator'),$expectedResult); + + $result = call_user_func(array('PHPExcel_Shared_String','getDecimalSeparator')); + $this->assertEquals($expectedResult, $result); + } + + public function testGetThousandsSeparator() + { + $localeconv = localeconv(); + + $expectedResult = (!empty($localeconv['thousands_sep'])) ? $localeconv['thousands_sep'] : ','; + $result = call_user_func(array('PHPExcel_Shared_String','getThousandsSeparator')); + $this->assertEquals($expectedResult, $result); + } + + public function testSetThousandsSeparator() + { + $expectedResult = ' '; + $result = call_user_func(array('PHPExcel_Shared_String','setThousandsSeparator'),$expectedResult); + + $result = call_user_func(array('PHPExcel_Shared_String','getThousandsSeparator')); + $this->assertEquals($expectedResult, $result); + } + + public function testGetCurrencyCode() + { + $localeconv = localeconv(); + + $expectedResult = (!empty($localeconv['currency_symbol'])) ? $localeconv['currency_symbol'] : '$'; + $result = call_user_func(array('PHPExcel_Shared_String','getCurrencyCode')); + $this->assertEquals($expectedResult, $result); + } + + public function testSetCurrencyCode() + { + $expectedResult = '£'; + $result = call_user_func(array('PHPExcel_Shared_String','setCurrencyCode'),$expectedResult); + + $result = call_user_func(array('PHPExcel_Shared_String','getCurrencyCode')); + $this->assertEquals($expectedResult, $result); + } + +} diff --git a/unitTests/rawTestData/Shared/CodePage.data b/unitTests/rawTestData/Shared/CodePage.data new file mode 100644 index 0000000..68ceda1 --- /dev/null +++ b/unitTests/rawTestData/Shared/CodePage.data @@ -0,0 +1,43 @@ +367, "ASCII" // ASCII +437, "CP437" // OEM US +737, "CP737" // OEM Greek +775, "CP775" // OEM Baltic +850, "CP850" // OEM Latin I +852, "CP852" // OEM Latin II (Central European) +855, "CP855" // OEM Cyrillic +857, "CP857" // OEM Turkish +858, "CP858" // OEM Multilingual Latin I with Euro +860, "CP860" // OEM Portugese +861, "CP861" // OEM Icelandic +862, "CP862" // OEM Hebrew +863, "CP863" // OEM Canadian (French) +864, "CP864" // OEM Arabic +865, "CP865" // OEM Nordic +866, "CP866" // OEM Cyrillic (Russian) +869, "CP869" // OEM Greek (Modern) +874, "CP874" // ANSI Thai +932, "CP932" // ANSI Japanese Shift-JIS +936, "CP936" // ANSI Chinese Simplified GBK +949, "CP949" // ANSI Korean (Wansung) +950, "CP950" // ANSI Chinese Traditional BIG5 +1200, "UTF-16LE" // UTF-16 (BIFF8) +1250, "CP1250" // ANSI Latin II (Central European) +1251, "CP1251" // ANSI Cyrillic +0, "CP1252" // ANSI Latin I (BIFF4-BIFF7) +1252, "CP1252" // ANSI Latin I (BIFF4-BIFF7) +1253, "CP1253" // ANSI Greek +1254, "CP1254" // ANSI Turkish +1255, "CP1255" // ANSI Hebrew +1256, "CP1256" // ANSI Arabic +1257, "CP1257" // ANSI Baltic +1258, "CP1258" // ANSI Vietnamese +1361, "CP1361" // ANSI Korean (Johab) +10000, "MAC" // Apple Roman +10006, "MACGREEK" // Macintosh Greek +10007, "MACCYRILLIC" // Macintosh Cyrillic +10029, "MACCENTRALEUROPE" // Macintosh Central Europe +10079, "MACICELAND" // Macintosh Icelandic +10081, "MACTURKISH" // Macintosh Turkish +32768, "MAC" // Apple Roman +65000, "UTF-7" // Unicode (UTF-7) +65001, "UTF-8" // Unicode (UTF-8)