-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
TranslationTest.php
51 lines (41 loc) · 1.57 KB
/
TranslationTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?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
{
private $compatibilityMode;
private $returnDate;
protected function setUp(): void
{
$this->compatibilityMode = Functions::getCompatibilityMode();
$this->returnDate = Functions::getReturnDateType();
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
}
protected function tearDown(): void
{
Functions::setCompatibilityMode($this->compatibilityMode);
Functions::setReturnDateType($this->returnDate);
}
/**
* @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()
{
return require 'tests/data/Calculation/Translations.php';
}
}