2012-06-18 20:35:21 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Shared;
|
2012-06-18 20:35:21 +00:00
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
2016-08-14 04:08:43 +00:00
|
|
|
|
2016-03-22 14:35:50 +00:00
|
|
|
class StringTest extends \PHPUnit_Framework_TestCase
|
2012-06-18 20:35:21 +00:00
|
|
|
{
|
2016-05-18 11:37:00 +00:00
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
// Reset Currency Code
|
2016-08-26 06:39:29 +00:00
|
|
|
StringHelper::setCurrencyCode(null);
|
2016-05-18 11:37:00 +00:00
|
|
|
}
|
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testGetIsMbStringEnabled()
|
|
|
|
{
|
2016-08-26 06:39:29 +00:00
|
|
|
$result = StringHelper::getIsMbstringEnabled();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertTrue($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetIsIconvEnabled()
|
|
|
|
{
|
2016-08-26 06:39:29 +00:00
|
|
|
$result = StringHelper::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-08-26 06:39:29 +00:00
|
|
|
$result = StringHelper::getDecimalSeparator();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetDecimalSeparator()
|
|
|
|
{
|
|
|
|
$expectedResult = ',';
|
2016-08-26 06:39:29 +00:00
|
|
|
StringHelper::setDecimalSeparator($expectedResult);
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-08-26 06:39:29 +00:00
|
|
|
$result = StringHelper::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-08-26 06:39:29 +00:00
|
|
|
$result = StringHelper::getThousandsSeparator();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetThousandsSeparator()
|
|
|
|
{
|
|
|
|
$expectedResult = ' ';
|
2016-08-26 06:39:29 +00:00
|
|
|
StringHelper::setThousandsSeparator($expectedResult);
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-08-26 06:39:29 +00:00
|
|
|
$result = StringHelper::getThousandsSeparator();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetCurrencyCode()
|
|
|
|
{
|
|
|
|
$localeconv = localeconv();
|
2016-05-18 11:37:00 +00:00
|
|
|
$expectedResult = (!empty($localeconv['currency_symbol']) ? $localeconv['currency_symbol'] : (!empty($localeconv['int_curr_symbol']) ? $localeconv['int_curr_symbol']: '$'));
|
2016-08-26 06:39:29 +00:00
|
|
|
$result = StringHelper::getCurrencyCode();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetCurrencyCode()
|
|
|
|
{
|
|
|
|
$expectedResult = '£';
|
2016-08-26 06:39:29 +00:00
|
|
|
StringHelper::setCurrencyCode($expectedResult);
|
2015-05-17 13:00:02 +00:00
|
|
|
|
2016-08-26 06:39:29 +00:00
|
|
|
$result = StringHelper::getCurrencyCode();
|
2015-05-17 13:00:02 +00:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
2012-06-18 20:35:21 +00:00
|
|
|
}
|