Minor Improvement to Test Cleanup MathTrig

Permit spreadsheet allocated as private member in test class to be garbage-collected after test completion.
This commit is contained in:
Owen Leibman 2021-05-13 18:22:59 -07:00 committed by Mark Baker
parent 9204d2d6b3
commit 4df184320a
74 changed files with 114 additions and 92 deletions

View File

@ -12,7 +12,7 @@ class AbsTest extends AllSetupTeardown
*/
public function testRound($expectedResult, $number = 'omitted'): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
$this->mightHaveException($expectedResult);
$this->setCell('A1', $number);
if ($number === 'omitted') {

View File

@ -12,7 +12,7 @@ class AcosTest extends AllSetupTeardown
public function testAcos($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A2')->setValue(0.5);
$sheet->getCell('A1')->setValue("=ACOS($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -12,7 +12,7 @@ class AcoshTest extends AllSetupTeardown
public function testAcosh($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A2')->setValue('1.5');
$sheet->getCell('A1')->setValue("=ACOSH($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -13,7 +13,7 @@ class AcotTest extends AllSetupTeardown
public function testACOT($expectedResult, $number): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class AcothTest extends AllSetupTeardown
public function testACOTH($expectedResult, $number): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -17,26 +17,28 @@ class AllSetupTeardown extends TestCase
private $compatibilityMode;
/**
* @var Spreadsheet
* @var ?Spreadsheet
*/
private $spreadsheet;
/**
* @var Worksheet
* @var ?Worksheet
*/
protected $sheet;
private $sheet;
protected function setUp(): void
{
$this->compatibilityMode = Functions::getCompatibilityMode();
$this->spreadsheet = new Spreadsheet();
$this->sheet = $this->spreadsheet->getActiveSheet();
}
protected function tearDown(): void
{
Functions::setCompatibilityMode($this->compatibilityMode);
$this->spreadsheet->disconnectWorksheets();
$this->sheet = null;
if ($this->spreadsheet !== null) {
$this->spreadsheet->disconnectWorksheets();
$this->spreadsheet = null;
}
}
protected static function setOpenOffice(): void
@ -66,10 +68,30 @@ class AllSetupTeardown extends TestCase
{
if ($value !== null) {
if (is_string($value) && is_numeric($value)) {
$this->sheet->getCell($cell)->setValueExplicit($value, DataType::TYPE_STRING);
$this->getSheet()->getCell($cell)->setValueExplicit($value, DataType::TYPE_STRING);
} else {
$this->sheet->getCell($cell)->setValue($value);
$this->getSheet()->getCell($cell)->setValue($value);
}
}
}
protected function getSpreadsheet(): Spreadsheet
{
if ($this->spreadsheet !== null) {
return $this->spreadsheet;
}
$this->spreadsheet = new Spreadsheet();
return $this->spreadsheet;
}
protected function getSheet(): Worksheet
{
if ($this->sheet !== null) {
return $this->sheet;
}
$this->sheet = $this->getSpreadsheet()->getActiveSheet();
return $this->sheet;
}
}

View File

@ -13,7 +13,7 @@ class ArabicTest extends AllSetupTeardown
public function testARABIC($expectedResult, $romanNumeral): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue($romanNumeral);
$sheet->getCell('B1')->setValue('=ARABIC(A1)');
$result = $sheet->getCell('B1')->getCalculatedValue();

View File

@ -12,7 +12,7 @@ class AsinTest extends AllSetupTeardown
public function testAsin($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A2')->setValue(0.5);
$sheet->getCell('A1')->setValue("=ASIN($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -12,7 +12,7 @@ class AsinhTest extends AllSetupTeardown
public function testAsinh($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A2')->setValue(0.5);
$sheet->getCell('A1')->setValue("=ASINH($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -12,7 +12,7 @@ class Atan2Test extends AllSetupTeardown
public function testATAN2($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A2')->setValue(5);
$sheet->getCell('A3')->setValue(6);
$sheet->getCell('A1')->setValue("=ATAN2($formula)");

View File

@ -12,7 +12,7 @@ class AtanTest extends AllSetupTeardown
public function testAtan($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A2')->setValue(5);
$sheet->getCell('A1')->setValue("=ATAN($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -12,7 +12,7 @@ class AtanhTest extends AllSetupTeardown
public function testAtanh($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A2')->setValue(0.8);
$sheet->getCell('A1')->setValue("=ATANH($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -15,7 +15,7 @@ class BaseTest extends AllSetupTeardown
public function testBASE($expectedResult, $arg1 = 'omitted', $arg2 = 'omitted', $arg3 = 'omitted'): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($arg1 !== null) {
$sheet->getCell('A1')->setValue($arg1);
}

View File

@ -13,7 +13,7 @@ class CeilingMathTest extends AllSetupTeardown
public function testCEILINGMATH($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class CeilingPreciseTest extends AllSetupTeardown
public function testCEILINGPRECISE($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class CeilingTest extends AllSetupTeardown
public function testCEILING($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);
@ -31,7 +31,7 @@ class CeilingTest extends AllSetupTeardown
public function testCEILINGGnumeric1Arg(): void
{
self::setGnumeric();
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue('=CEILING(5.1)');
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEqualsWithDelta(6, $result, 1E-12);
@ -40,7 +40,7 @@ class CeilingTest extends AllSetupTeardown
public function testCELINGOpenOffice1Arg(): void
{
self::setOpenOffice();
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue('=CEILING(5.1)');
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEqualsWithDelta(6, $result, 1E-12);
@ -49,7 +49,7 @@ class CeilingTest extends AllSetupTeardown
public function testCEILINGExcel1Arg(): void
{
$this->mightHaveException('exception');
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue('=CEILING(5.1)');
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEqualsWithDelta(6, $result, 1E-12);

View File

@ -14,7 +14,7 @@ class CombinATest extends AllSetupTeardown
public function testCOMBINA($expectedResult, $numObjs, $numInSet): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($numObjs !== null) {
$sheet->getCell('A1')->setValue($numObjs);
}

View File

@ -14,7 +14,7 @@ class CombinTest extends AllSetupTeardown
public function testCOMBIN($expectedResult, $numObjs, $numInSet): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($numObjs !== null) {
$sheet->getCell('A1')->setValue($numObjs);
}

View File

@ -12,7 +12,7 @@ class CosTest extends AllSetupTeardown
public function testCos($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 2);
$sheet->getCell('A1')->setValue("=COS($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -12,7 +12,7 @@ class CoshTest extends AllSetupTeardown
public function testCosh($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 2);
$sheet->getCell('A1')->setValue("=COSH($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -13,7 +13,7 @@ class CotTest extends AllSetupTeardown
public function testCOT($expectedResult, $angle): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class CothTest extends AllSetupTeardown
public function testCOTH($expectedResult, $angle): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class CscTest extends AllSetupTeardown
public function testCSC($expectedResult, $angle): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class CschTest extends AllSetupTeardown
public function testCSCH($expectedResult, $angle): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -12,7 +12,7 @@ class DegreesTest extends AllSetupTeardown
*/
public function testDegrees($expectedResult, $number = 'omitted'): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
$this->mightHaveException($expectedResult);
$this->setCell('A1', $number);
if ($number === 'omitted') {

View File

@ -13,7 +13,7 @@ class EvenTest extends AllSetupTeardown
public function testEVEN($expectedResult, $value): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue("=EVEN($value)");
$sheet->getCell('A2')->setValue(3.7);
self::assertEquals($expectedResult, $sheet->getCell('A1')->getCalculatedValue());

View File

@ -13,7 +13,7 @@ class ExpTest extends AllSetupTeardown
public function testEXP($expectedResult, $number = 'omitted'): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($number !== null) {
$sheet->getCell('A1')->setValue($number);
}

View File

@ -13,7 +13,7 @@ class FactDoubleTest extends AllSetupTeardown
public function testFACTDOUBLE($expectedResult, $value): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue($value);
$sheet->getCell('B1')->setValue('=FACTDOUBLE(A1)');
$result = $sheet->getCell('B1')->getCalculatedValue();

View File

@ -13,7 +13,7 @@ class FactTest extends AllSetupTeardown
public function testFACT($expectedResult, $arg1): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($arg1 !== null) {
$sheet->getCell('A1')->setValue($arg1);
}
@ -41,7 +41,7 @@ class FactTest extends AllSetupTeardown
{
$this->mightHaveException($expectedResult);
self::setGnumeric();
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($arg1 !== null) {
$sheet->getCell('A1')->setValue($arg1);
}

View File

@ -13,7 +13,7 @@ class FloorMathTest extends AllSetupTeardown
public function testFLOORMATH($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class FloorPreciseTest extends AllSetupTeardown
public function testFLOORPRECISE($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class FloorTest extends AllSetupTeardown
public function testFLOOR($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);
@ -31,7 +31,7 @@ class FloorTest extends AllSetupTeardown
public function testFLOORGnumeric1Arg(): void
{
self::setGnumeric();
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue('=FLOOR(5.1)');
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEqualsWithDelta(5, $result, 1E-12);
@ -40,7 +40,7 @@ class FloorTest extends AllSetupTeardown
public function testFLOOROpenOffice1Arg(): void
{
self::setOpenOffice();
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue('=FLOOR(5.1)');
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEqualsWithDelta(5, $result, 1E-12);
@ -49,7 +49,7 @@ class FloorTest extends AllSetupTeardown
public function testFLOORExcel1Arg(): void
{
$this->mightHaveException('exception');
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue('=FLOOR(5.1)');
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEqualsWithDelta(5, $result, 1E-12);

View File

@ -12,7 +12,7 @@ class GcdTest extends AllSetupTeardown
public function testGCD($expectedResult, ...$args): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$row = 0;
foreach ($args as $arg) {
++$row;

View File

@ -13,7 +13,7 @@ class IntTest extends AllSetupTeardown
public function testINT($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -11,7 +11,7 @@ class LcmTest extends AllSetupTeardown
*/
public function testLCM($expectedResult, ...$args): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
$row = 0;
foreach ($args as $arg) {
++$row;

View File

@ -13,7 +13,7 @@ class LnTest extends AllSetupTeardown
public function testLN($expectedResult, $number = 'omitted'): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($number !== null) {
$sheet->getCell('A1')->setValue($number);
}

View File

@ -13,7 +13,7 @@ class Log10Test extends AllSetupTeardown
public function testLN($expectedResult, $number = 'omitted'): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($number !== null) {
$sheet->getCell('A1')->setValue($number);
}

View File

@ -14,7 +14,7 @@ class LogTest extends AllSetupTeardown
public function testLOG($expectedResult, $number = 'omitted', $base = 'omitted'): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($number !== null) {
$sheet->getCell('A1')->setValue($number);
}

View File

@ -25,7 +25,7 @@ class MInverseTest extends AllSetupTeardown
public function testOnSpreadsheet(): void
{
// very limited ability to test this in the absence of dynamic arrays
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue('=MINVERSE({1,2,3})'); // not square
self::assertSame('#VALUE!', $sheet->getCell('A1')->getCalculatedValue());
}

View File

@ -25,7 +25,7 @@ class MMultTest extends AllSetupTeardown
public function testOnSpreadsheet(): void
{
// very limited ability to test this in the absence of dynamic arrays
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue('=MMULT({1,2,3}, {1,2,3})'); // incompatible dimensions
self::assertSame('#VALUE!', $sheet->getCell('A1')->getCalculatedValue());

View File

@ -13,7 +13,7 @@ class MRoundTest extends AllSetupTeardown
public function testMROUND($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class MdeTermTest extends AllSetupTeardown
public function testMDETERM2($expectedResult, $matrix): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if (is_array($matrix)) {
$sheet->fromArray($matrix, null, 'A1', true);
$maxCol = $sheet->getHighestColumn();

View File

@ -14,7 +14,7 @@ class ModTest extends AllSetupTeardown
public function testMOD($expectedResult, $dividend = 'omitted', $divisor = 'omitted'): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($dividend !== null) {
$sheet->getCell('A1')->setValue($dividend);
}

View File

@ -12,7 +12,7 @@ class MultinomialTest extends AllSetupTeardown
public function testMULTINOMIAL($expectedResult, ...$args): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$row = 0;
$excelArg = '';
foreach ($args as $arg) {

View File

@ -13,7 +13,7 @@ class OddTest extends AllSetupTeardown
public function testODD($expectedResult, $value): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('A1')->setValue("=ODD($value)");
$sheet->getCell('A2')->setValue(3.7);
self::assertEquals($expectedResult, $sheet->getCell('A1')->getCalculatedValue());

View File

@ -14,7 +14,7 @@ class PowerTest extends AllSetupTeardown
public function testPOWER($expectedResult, $base = 'omitted', $exponent = 'omitted'): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($base !== null) {
$sheet->getCell('A1')->setValue($base);
}

View File

@ -11,7 +11,7 @@ class ProductTest extends AllSetupTeardown
*/
public function testPRODUCT($expectedResult, ...$args): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
$row = 0;
foreach ($args as $arg) {
++$row;

View File

@ -14,7 +14,7 @@ class QuotientTest extends AllSetupTeardown
public function testQUOTIENT($expectedResult, $arg1 = 'omitted', $arg2 = 'omitted'): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($arg1 !== null) {
$sheet->getCell('A1')->setValue($arg1);
}

View File

@ -12,7 +12,7 @@ class RadiansTest extends AllSetupTeardown
*/
public function testRADIANS($expectedResult, $number = 'omitted'): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
$this->mightHaveException($expectedResult);
$this->setCell('A1', $number);
if ($number === 'omitted') {

View File

@ -14,7 +14,7 @@ class RandBetweenTest extends AllSetupTeardown
public function testRANDBETWEEN($expectedResult, $min = 'omitted', $max = 'omitted'): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$lower = (int) $min;
$upper = (int) $max;
if ($min !== null) {

View File

@ -6,7 +6,7 @@ class RandTest extends AllSetupTeardown
{
public function testRand(): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('B1')->setValue('=RAND()');
$result = $sheet->getCell('B1')->getCalculatedValue();
self::assertGreaterThanOrEqual(0, $result);
@ -16,7 +16,7 @@ class RandTest extends AllSetupTeardown
public function testRandException(): void
{
$this->mightHaveException('exception');
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->getCell('B1')->setValue('=RAND(A1)');
$result = $sheet->getCell('B1')->getCalculatedValue();
self::assertEquals(0, $result);

View File

@ -13,7 +13,7 @@ class RomanTest extends AllSetupTeardown
public function testROMAN($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A3', 49);
$sheet->getCell('A1')->setValue("=ROMAN($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -13,7 +13,7 @@ class RoundDownTest extends AllSetupTeardown
public function testRoundDown($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class RoundTest extends AllSetupTeardown
public function testRound($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class RoundUpTest extends AllSetupTeardown
public function testRoundUp($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class SecTest extends AllSetupTeardown
public function testSEC($expectedResult, $angle): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -13,7 +13,7 @@ class SechTest extends AllSetupTeardown
public function testSECH($expectedResult, $angle): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);

View File

@ -16,7 +16,7 @@ class SeriesSumTest extends AllSetupTeardown
*/
public function testSERIESSUM($expectedResult, $arg1, $arg2, $arg3, ...$args): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($arg1 !== null) {
$sheet->getCell('C1')->setValue($arg1);
}

View File

@ -13,7 +13,7 @@ class SignTest extends AllSetupTeardown
public function testSIGN($expectedResult, $value): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 0);
$sheet->setCellValue('A4', -3.8);

View File

@ -12,7 +12,7 @@ class SinTest extends AllSetupTeardown
public function testSin($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 2);
$sheet->getCell('A1')->setValue("=SIN($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -12,7 +12,7 @@ class SinhTest extends AllSetupTeardown
public function testSinh($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 2);
$sheet->getCell('A1')->setValue("=SINH($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -13,7 +13,7 @@ class SqrtPiTest extends AllSetupTeardown
public function testSQRTPI($expectedResult, $number): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
if ($number !== null) {
$sheet->getCell('A1')->setValue($number);
}

View File

@ -12,7 +12,7 @@ class SqrtTest extends AllSetupTeardown
*/
public function testSQRT($expectedResult, $number = 'omitted'): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
$this->mightHaveException($expectedResult);
$this->setCell('A1', $number);
if ($number === 'omitted') {

View File

@ -13,7 +13,7 @@ class SubTotalTest extends AllSetupTeardown
public function testSubtotal($expectedResult, $type): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->fromArray([[0], [1], [1], [2], [3], [5], [8], [13], [21], [34], [55], [89]], null, 'A1', true);
$maxCol = $sheet->getHighestColumn();
$maxRow = $sheet->getHighestRow();
@ -37,7 +37,7 @@ class SubTotalTest extends AllSetupTeardown
{
// Hidden columns don't affect calculation, only hidden rows
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->fromArray([0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89], null, 'A1', true);
$maxCol = $sheet->getHighestColumn();
$maxRow = $sheet->getHighestRow();
@ -73,7 +73,7 @@ class SubTotalTest extends AllSetupTeardown
public function testSubtotalRowHidden($expectedResult, $type): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->fromArray([[0], [1], [1], [2], [3], [5], [8], [13], [21], [34], [55], [89]], null, 'A1', true);
$maxCol = $sheet->getHighestColumn();
$maxRow = $sheet->getHighestRow();
@ -107,7 +107,7 @@ class SubTotalTest extends AllSetupTeardown
public function testSubtotalNested(): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->fromArray(
[
[123],

View File

@ -16,7 +16,7 @@ class SumIfTest extends AllSetupTeardown
if ($expectedResult === 'incomplete') {
self::markTestIncomplete('Raises formula error - researching solution');
}
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->fromArray($array1, null, 'A1', true);
$maxARow = count($array1);
$firstArg = "A1:A$maxARow";

View File

@ -13,7 +13,7 @@ class SumProductTest extends AllSetupTeardown
*/
public function testSUMPRODUCT($expectedResult, ...$args): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
$row = 0;
$arrayArg = '';
foreach ($args as $arr) {

View File

@ -14,7 +14,7 @@ class SumSqTest extends AllSetupTeardown
$this->mightHaveException($expectedResult);
$maxRow = 0;
$funcArg = '';
$sheet = $this->sheet;
$sheet = $this->getSheet();
foreach ($args as $arg) {
++$maxRow;
$funcArg = "A1:A$maxRow";

View File

@ -11,7 +11,7 @@ class SumTest extends AllSetupTeardown
*/
public function testSUM($expectedResult, ...$args): void
{
$sheet = $this->sheet;
$sheet = $this->getSheet();
$row = 0;
foreach ($args as $arg) {
++$row;

View File

@ -14,7 +14,7 @@ class SumX2MY2Test extends AllSetupTeardown
public function testSUMX2MY2($expectedResult, array $matrixData1, array $matrixData2): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$maxRow = 0;
$funcArg1 = '';
foreach (Functions::flattenArray($matrixData1) as $arg) {

View File

@ -14,7 +14,7 @@ class SumX2PY2Test extends AllSetupTeardown
public function testSUMX2PY2($expectedResult, array $matrixData1, array $matrixData2): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$maxRow = 0;
$funcArg1 = '';
foreach (Functions::flattenArray($matrixData1) as $arg) {

View File

@ -14,7 +14,7 @@ class SumXMY2Test extends AllSetupTeardown
public function testSUMXMY2($expectedResult, array $matrixData1, array $matrixData2): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$maxRow = 0;
$funcArg1 = '';
foreach (Functions::flattenArray($matrixData1) as $arg) {

View File

@ -12,7 +12,7 @@ class TanTest extends AllSetupTeardown
public function testTan($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1);
$sheet->getCell('A1')->setValue("=TAN($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -12,7 +12,7 @@ class TanhTest extends AllSetupTeardown
public function testTanh($expectedResult, string $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1);
$sheet->getCell('A1')->setValue("=TANH($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();

View File

@ -13,7 +13,7 @@ class TruncTest extends AllSetupTeardown
public function testTRUNC($expectedResult, $formula): void
{
$this->mightHaveException($expectedResult);
$sheet = $this->sheet;
$sheet = $this->getSheet();
$sheet->setCellValue('A2', 1.3);
$sheet->setCellValue('A3', 2.7);
$sheet->setCellValue('A4', -3.8);