PhpSpreadsheet/tests/PhpSpreadsheetTests/Shared/StringTest.php

82 lines
2.6 KiB
PHP
Raw Normal View History

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