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

74 lines
2.5 KiB
PHP
Raw Normal View History

<?php
require_once 'testDataFileIterator.php';
class StringTest extends PHPUnit_Framework_TestCase
{
2015-05-17 13:00:02 +00:00
public function testGetIsMbStringEnabled()
{
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','getIsMbstringEnabled'));
2015-05-17 13:00:02 +00:00
$this->assertTrue($result);
}
public function testGetIsIconvEnabled()
{
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','getIsIconvEnabled'));
2015-05-17 13:00:02 +00:00
$this->assertTrue($result);
}
public function testGetDecimalSeparator()
{
$localeconv = localeconv();
$expectedResult = (!empty($localeconv['decimal_point'])) ? $localeconv['decimal_point'] : ',';
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','getDecimalSeparator'));
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function testSetDecimalSeparator()
{
$expectedResult = ',';
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','setDecimalSeparator'), $expectedResult);
2015-05-17 13:00:02 +00:00
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','getDecimalSeparator'));
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function testGetThousandsSeparator()
{
$localeconv = localeconv();
$expectedResult = (!empty($localeconv['thousands_sep'])) ? $localeconv['thousands_sep'] : ',';
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','getThousandsSeparator'));
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function testSetThousandsSeparator()
{
$expectedResult = ' ';
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','setThousandsSeparator'), $expectedResult);
2015-05-17 13:00:02 +00:00
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','getThousandsSeparator'));
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function testGetCurrencyCode()
{
$localeconv = localeconv();
$expectedResult = (!empty($localeconv['currency_symbol'])) ? $localeconv['currency_symbol'] : '$';
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','getCurrencyCode'));
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function testSetCurrencyCode()
{
$expectedResult = '£';
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','setCurrencyCode'), $expectedResult);
2015-05-17 13:00:02 +00:00
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\String','getCurrencyCode'));
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
}