69 lines
1.8 KiB
PHP
69 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
|
|
|
class ValueTest extends AllSetupTeardown
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $currencyCode;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $decimalSeparator;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $thousandsSeparator;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->currencyCode = StringHelper::getCurrencyCode();
|
|
$this->decimalSeparator = StringHelper::getDecimalSeparator();
|
|
$this->thousandsSeparator = StringHelper::getThousandsSeparator();
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
parent::tearDown();
|
|
StringHelper::setCurrencyCode($this->currencyCode);
|
|
StringHelper::setDecimalSeparator($this->decimalSeparator);
|
|
StringHelper::setThousandsSeparator($this->thousandsSeparator);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerVALUE
|
|
*
|
|
* @param mixed $expectedResult
|
|
* @param mixed $value
|
|
*/
|
|
public function testVALUE($expectedResult, $value = 'omitted'): void
|
|
{
|
|
StringHelper::setDecimalSeparator('.');
|
|
StringHelper::setThousandsSeparator(' ');
|
|
StringHelper::setCurrencyCode('$');
|
|
|
|
$this->mightHaveException($expectedResult);
|
|
$sheet = $this->getSheet();
|
|
if ($value === 'omitted') {
|
|
$sheet->getCell('B1')->setValue('=VALUE()');
|
|
} else {
|
|
$this->setCell('A1', $value);
|
|
$sheet->getCell('B1')->setValue('=VALUE(A1)');
|
|
}
|
|
$result = $sheet->getCell('B1')->getCalculatedValue();
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1E-8);
|
|
}
|
|
|
|
public function providerVALUE(): array
|
|
{
|
|
return require 'tests/data/Calculation/TextData/VALUE.php';
|
|
}
|
|
}
|