Files
MarkBaker 541bf0f876 Merge branch 'master' into 2.0-Development
# Conflicts:
#	docs/topics/calculation-engine.md
#	phpstan-baseline.neon
#	src/PhpSpreadsheet/Reader/Xlsx.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IrrTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php
2022-09-25 16:57:54 +02:00

63 lines
1.8 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Settings;
use PHPUnit\Framework\TestCase;
class TranslationTest extends TestCase
{
/**
* @var string
*/
private $compatibilityMode;
/**
* @var string
*/
private $returnDate;
/** @var string */
private $locale;
protected function setUp(): void
{
$this->compatibilityMode = Functions::getCompatibilityMode();
$this->returnDate = Functions::getReturnDateType();
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
$this->locale = Settings::getLocale();
}
protected function tearDown(): void
{
Functions::setCompatibilityMode($this->compatibilityMode);
Functions::setReturnDateType($this->returnDate);
Settings::setLocale($this->locale);
}
/**
* @dataProvider providerTranslations
*/
public function testTranslation(string $expectedResult, string $locale, string $formula): void
{
$validLocale = Settings::setLocale($locale);
if (!$validLocale) {
self::markTestSkipped("Unable to set locale to {$locale}");
}
$translatedFormula = Calculation::getInstance()->translateFormulaToLocale($formula);
self::assertSame($expectedResult, $translatedFormula);
$restoredFormula = Calculation::getInstance()->translateFormulaToEnglish($translatedFormula);
self::assertSame($formula, $restoredFormula);
}
public function providerTranslations(): array
{
return require 'tests/data/Calculation/Translations.php';
}
}