diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php index 80431c4d..8e339207 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -9,15 +9,23 @@ use PHPUnit\Framework\TestCase; class CalculationTest extends TestCase { + private $compatibilityMode; + + private $locale; + protected function setUp(): void { + $this->compatibilityMode = Functions::getCompatibilityMode(); + $calculation = Calculation::getInstance(); + $this->locale = $calculation->getLocale(); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } protected function tearDown(): void { + Functions::setCompatibilityMode($this->compatibilityMode); $calculation = Calculation::getInstance(); - $calculation->setLocale('en_us'); + $calculation->setLocale($this->locale); } /** diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php index 8f4639eb..482e068d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php @@ -9,13 +9,29 @@ use PHPUnit\Framework\TestCase; class DayTest extends TestCase { + private $compatibilityMode; + + private $returnDateType; + + private $excelCalendar; + protected function setUp(): void { + $this->compatibilityMode = Functions::getCompatibilityMode(); + $this->returnDateType = Functions::getReturnDateType(); + $this->excelCalendar = Date::getExcelCalendar(); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); } + protected function tearDown(): void + { + Functions::setCompatibilityMode($this->compatibilityMode); + Functions::setReturnDateType($this->returnDateType); + Date::setExcelCalendar($this->excelCalendar); + } + /** * @dataProvider providerDAY * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php index 26e621ec..65b698e3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php @@ -8,11 +8,19 @@ use PHPUnit\Framework\TestCase; class CountTest extends TestCase { + private $compatibilityMode; + protected function setUp(): void { + $this->compatibilityMode = Functions::getCompatibilityMode(); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } + protected function tearDown(): void + { + Functions::setCompatibilityMode($this->compatibilityMode); + } + /** * @dataProvider providerBasicCOUNT * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php index 70ea7526..cf22df02 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class CharTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerCHAR * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php index 6aedb599..31dcc5e6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class CleanTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerCLEAN * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php index ec9f26d6..9c19f347 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class CodeTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerCODE * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php index 18a2d684..068e7d8f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class ConcatenateTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerCONCATENATE * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php index 4a0f6013..1d482589 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class DollarTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerDOLLAR * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php index 09d45a32..92d3935c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class ExactTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerEXACT * @@ -33,10 +15,6 @@ class ExactTest extends TestCase */ public function testEXACT($expectedResult, ...$args): void { - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(' '); - StringHelper::setCurrencyCode('$'); - $result = TextData::EXACT(...$args); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php index 38203a33..d4b1b77d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class FindTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerFIND * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php index 53e6a513..0cbaf80c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class FixedTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerFIXED * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php index 9a033ae7..e69a3fa0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class LeftTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerLEFT * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php index af784163..bca2b389 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class LenTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerLEN * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php index 6ad522d8..9ba677c7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class LowerTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerLOWER * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php index df02575f..4c19248a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class MidTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerMID * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php index 006e4ce1..c186bb0b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class NumberValueTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerNUMBERVALUE * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php index d799b395..aae0e696 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class ProperTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerPROPER * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php index ff3d58bb..ff9236e6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class ReplaceTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerREPLACE * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php index a89ea6ed..50fc86dc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class RightTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerRIGHT * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php index 919ec0fb..7bb92e83 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class SearchTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerSEARCH * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php index d1884fd8..2a9d1012 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class SubstituteTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerSUBSTITUTE * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php index 1ce989b4..c7606c05 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class TTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerT * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php index 7eec585c..e8fb404d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class TextJoinTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerTEXTJOIN * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php index eab517cc..8d7b238b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class TextTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerTEXT * @@ -32,11 +14,6 @@ class TextTest extends TestCase */ public function testTEXT($expectedResult, ...$args): void { - // Enforce decimal and thousands separator values to UK/US, and currency code to USD - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - $result = TextData::TEXTFORMAT(...$args); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php index 24ede75f..91890ded 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class TrimTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerTRIM * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php index 1600f37c..13fb0b86 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -2,29 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class UpperTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - - protected function tearDown(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); - } - /** * @dataProvider providerUPPER * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php index a5083b22..355193de 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php @@ -2,27 +2,30 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit\Framework\TestCase; class ValueTest extends TestCase { + private $currencyCode; + + private $decimalSeparator; + + private $thousandsSeparator; + protected function setUp(): void { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); + $this->currencyCode = StringHelper::getCurrencyCode(); + $this->decimalSeparator = StringHelper::getDecimalSeparator(); + $this->thousandsSeparator = StringHelper::getThousandsSeparator(); } protected function tearDown(): void { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - StringHelper::setDecimalSeparator('.'); - StringHelper::setThousandsSeparator(','); - StringHelper::setCurrencyCode('$'); + StringHelper::setCurrencyCode($this->currencyCode); + StringHelper::setDecimalSeparator($this->decimalSeparator); + StringHelper::setThousandsSeparator($this->thousandsSeparator); } /** diff --git a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php index 4412215a..dfa01822 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php @@ -10,16 +10,22 @@ use PHPUnit\Framework\TestCase; class FunctionsTest 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(Functions::COMPATIBILITY_EXCEL); - Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); + Functions::setCompatibilityMode($this->compatibilityMode); + Functions::setReturnDateType($this->returnDate); } public function testCompatibilityMode(): void diff --git a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php index 936092d4..630a2944 100644 --- a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php @@ -13,6 +13,26 @@ use PHPUnit\Framework\TestCase; class AdvancedValueBinderTest extends TestCase { + private $currencyCode; + + private $decimalSeparator; + + private $thousandsSeparator; + + protected function setUp(): void + { + $this->currencyCode = StringHelper::getCurrencyCode(); + $this->decimalSeparator = StringHelper::getDecimalSeparator(); + $this->thousandsSeparator = StringHelper::getThousandsSeparator(); + } + + protected function tearDown(): void + { + StringHelper::setCurrencyCode($this->currencyCode); + StringHelper::setDecimalSeparator($this->decimalSeparator); + StringHelper::setThousandsSeparator($this->thousandsSeparator); + } + public function provider() { $currencyUSD = NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; diff --git a/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php b/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php index b11bf764..41ed0b21 100644 --- a/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php +++ b/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php @@ -7,14 +7,30 @@ use PHPUnit\Framework\TestCase; class StringHelperTest extends TestCase { + private $currencyCode; + + private $decimalSeparator; + + private $thousandsSeparator; + protected function setUp(): void { parent::setUp(); + $this->currencyCode = StringHelper::getCurrencyCode(); + $this->decimalSeparator = StringHelper::getDecimalSeparator(); + $this->thousandsSeparator = StringHelper::getThousandsSeparator(); // Reset Currency Code StringHelper::setCurrencyCode(null); } + protected function tearDown(): void + { + StringHelper::setCurrencyCode($this->currencyCode); + StringHelper::setDecimalSeparator($this->decimalSeparator); + StringHelper::setThousandsSeparator($this->thousandsSeparator); + } + public function testGetIsIconvEnabled(): void { $result = StringHelper::getIsIconvEnabled(); diff --git a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php index e995eded..6bf7db04 100644 --- a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php @@ -8,12 +8,28 @@ use PHPUnit\Framework\TestCase; class NumberFormatTest extends TestCase { + private $currencyCode; + + private $decimalSeparator; + + private $thousandsSeparator; + protected function setUp(): void { + $this->currencyCode = StringHelper::getCurrencyCode(); + $this->decimalSeparator = StringHelper::getDecimalSeparator(); + $this->thousandsSeparator = StringHelper::getThousandsSeparator(); StringHelper::setDecimalSeparator('.'); StringHelper::setThousandsSeparator(','); } + protected function tearDown(): void + { + StringHelper::setCurrencyCode($this->currencyCode); + StringHelper::setDecimalSeparator($this->decimalSeparator); + StringHelper::setThousandsSeparator($this->thousandsSeparator); + } + /** * @dataProvider providerNumberFormat * diff --git a/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php b/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php index 9d306fa0..340e820b 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php @@ -10,12 +10,16 @@ use PhpOffice\PhpSpreadsheetTests\Functional; class HtmlNumberFormatTest extends Functional\AbstractFunctional { + private $currency; + private $decsep; private $thosep; protected function setUp(): void { + $this->currency = StringHelper::getCurrencyCode(); + StringHelper::setCurrencyCode('$'); $this->decsep = StringHelper::getDecimalSeparator(); StringHelper::setDecimalSeparator('.'); $this->thosep = StringHelper::getThousandsSeparator(); @@ -24,6 +28,7 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional protected function tearDown(): void { + StringHelper::setCurrencyCode($this->currency); StringHelper::setDecimalSeparator($this->decsep); StringHelper::setThousandsSeparator($this->thosep); }