PhpSpreadsheet/tests/PhpSpreadsheetTests/Shared/StringTest.php

82 lines
2.3 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
StringHelper::setCurrencyCode(null);
}
2015-05-17 13:00:02 +00:00
public function testGetIsMbStringEnabled()
{
$result = StringHelper::getIsMbstringEnabled();
2015-05-17 13:00:02 +00:00
$this->assertTrue($result);
}
public function testGetIsIconvEnabled()
{
$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'] : ',';
$result = StringHelper::getDecimalSeparator();
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function testSetDecimalSeparator()
{
$expectedResult = ',';
StringHelper::setDecimalSeparator($expectedResult);
2015-05-17 13:00:02 +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'] : ',';
$result = StringHelper::getThousandsSeparator();
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function testSetThousandsSeparator()
{
$expectedResult = ' ';
StringHelper::setThousandsSeparator($expectedResult);
2015-05-17 13:00:02 +00:00
$result = StringHelper::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 = StringHelper::getCurrencyCode();
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function testSetCurrencyCode()
{
$expectedResult = '£';
StringHelper::setCurrencyCode($expectedResult);
2015-05-17 13:00:02 +00:00
$result = StringHelper::getCurrencyCode();
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
}