Restoring State After Static Changes in Tests (#1571)
This request does not change any source code, only tests. For a change on which I was working, a test passed when run on its own, but failed when run as part of the full test suite. It turned out that an existing test had changed a static value, thousands separator in this case, and failed to restore it. The test turned out to be AdvancedBinderTest. The search for the offending test was more difficult than it should have been because 26 test scripts which had nothing to do with thousands separator nevertheless changed that value. They all changed decimal separator, currency code, and compatibility mode as well, again for no reason. I changed all of those to eliminate those operations. I changed the following tests, which actually do change the static properties identified above for a reason, to restore them as part of teardown. - CalculationTest sets compatibilityMode and locale - DayTest sets compatibilityMode, returnDateType, and excelCalendar - CountTest sets compatibilityMode - FunctionsTest sets compatibilityMode and returnDateType - AdvancedValueBinderTest sets currencyCode, decimalSeparator, thousandsSeparator - StringHelperTest sets currencyCode, decimalSeparator, thousandsSeparator - NumberFormatTest sets currencyCode, decimalSeparator, thousandsSeparator - HtmlNumberFormatTest sets currencyCode, decimalSeparator, thousandsSeparator
This commit is contained in:
parent
b89968d206
commit
165034ad70
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue