mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-10-01 01:19:11 +00:00
Respect PSR-0 with matching folder name and namespace PhpSpreadsheetTests
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace PhpSpreadsheetTests\Shared;
|
||||
|
||||
use PhpSpreadsheet\Shared\StringHelper;
|
||||
|
||||
class StringTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Reset Currency Code
|
||||
call_user_func([StringHelper::class, 'setCurrencyCode'], null);
|
||||
}
|
||||
|
||||
public function testGetIsMbStringEnabled()
|
||||
{
|
||||
$result = call_user_func([StringHelper::class, 'getIsMbstringEnabled']);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testGetIsIconvEnabled()
|
||||
{
|
||||
$result = call_user_func([StringHelper::class, 'getIsIconvEnabled']);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testGetDecimalSeparator()
|
||||
{
|
||||
$localeconv = localeconv();
|
||||
|
||||
$expectedResult = (!empty($localeconv['decimal_point'])) ? $localeconv['decimal_point'] : ',';
|
||||
$result = call_user_func([StringHelper::class, 'getDecimalSeparator']);
|
||||
$this->assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetDecimalSeparator()
|
||||
{
|
||||
$expectedResult = ',';
|
||||
call_user_func([StringHelper::class, 'setDecimalSeparator'], $expectedResult);
|
||||
|
||||
$result = call_user_func([StringHelper::class, 'getDecimalSeparator']);
|
||||
$this->assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testGetThousandsSeparator()
|
||||
{
|
||||
$localeconv = localeconv();
|
||||
|
||||
$expectedResult = (!empty($localeconv['thousands_sep'])) ? $localeconv['thousands_sep'] : ',';
|
||||
$result = call_user_func([StringHelper::class, 'getThousandsSeparator']);
|
||||
$this->assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetThousandsSeparator()
|
||||
{
|
||||
$expectedResult = ' ';
|
||||
call_user_func([StringHelper::class, 'setThousandsSeparator'], $expectedResult);
|
||||
|
||||
$result = call_user_func([StringHelper::class, 'getThousandsSeparator']);
|
||||
$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']);
|
||||
$this->assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetCurrencyCode()
|
||||
{
|
||||
$expectedResult = '£';
|
||||
call_user_func([StringHelper::class, 'setCurrencyCode'], $expectedResult);
|
||||
|
||||
$result = call_user_func([StringHelper::class, 'getCurrencyCode']);
|
||||
$this->assertEquals($expectedResult, $result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user