Fix unit tests for PHP 5.6
This commit is contained in:
parent
216cbadd8c
commit
064076ac6d
|
@ -1073,6 +1073,7 @@ class MathTrig
|
||||||
$args,
|
$args,
|
||||||
function ($index) use ($cellReference) {
|
function ($index) use ($cellReference) {
|
||||||
list(, $row, $column) = explode('.', $index);
|
list(, $row, $column) = explode('.', $index);
|
||||||
|
|
||||||
return $cellReference->getWorksheet()->getRowDimension($row)->getVisible() &&
|
return $cellReference->getWorksheet()->getRowDimension($row)->getVisible() &&
|
||||||
$cellReference->getWorksheet()->getColumnDimension($column)->getVisible();
|
$cellReference->getWorksheet()->getColumnDimension($column)->getVisible();
|
||||||
},
|
},
|
||||||
|
@ -1090,8 +1091,10 @@ class MathTrig
|
||||||
//take this cell out if it contains the SUBTOTAL formula
|
//take this cell out if it contains the SUBTOTAL formula
|
||||||
$isFormula = $cellReference->getWorksheet()->getCell($column . $row)->isFormula();
|
$isFormula = $cellReference->getWorksheet()->getCell($column . $row)->isFormula();
|
||||||
$cellFormula = !preg_match('/^=.*\bSUBTOTAL\s*\(/', strtoupper($cellReference->getWorksheet()->getCell($column . $row)->getValue()));
|
$cellFormula = !preg_match('/^=.*\bSUBTOTAL\s*\(/', strtoupper($cellReference->getWorksheet()->getCell($column . $row)->getValue()));
|
||||||
|
|
||||||
return !$isFormula || $cellFormula;
|
return !$isFormula || $cellFormula;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
ARRAY_FILTER_USE_KEY
|
ARRAY_FILTER_USE_KEY
|
||||||
|
|
|
@ -5,10 +5,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
||||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||||
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\RowDimension;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\RowDimension;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class MathTrigTest extends TestCase
|
class MathTrigTest extends TestCase
|
||||||
|
@ -542,8 +542,12 @@ class MathTrigTest extends TestCase
|
||||||
return require 'data/Calculation/MathTrig/SUBTOTAL.php';
|
return require 'data/Calculation/MathTrig/SUBTOTAL.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function rowVisibility() {
|
protected function rowVisibility()
|
||||||
yield from [1 => false, 2 => true, 3 => false, 4 => true, 5 => false, 6 => false, 7 => false, 8 => true, 9 => false, 10 => true, 11 =>true];
|
{
|
||||||
|
$data = [1 => false, 2 => true, 3 => false, 4 => true, 5 => false, 6 => false, 7 => false, 8 => true, 9 => false, 10 => true, 11 => true];
|
||||||
|
foreach ($data as $k => $v) {
|
||||||
|
yield $k => $v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -560,7 +564,12 @@ class MathTrigTest extends TestCase
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$rowDimension->method('getVisible')
|
$rowDimension->method('getVisible')
|
||||||
->will($this->returnCallback(function() use ($visibilityGenerator) { $result = $visibilityGenerator->current(); $visibilityGenerator->next(); return $result; }));
|
->will($this->returnCallback(function () use ($visibilityGenerator) {
|
||||||
|
$result = $visibilityGenerator->current();
|
||||||
|
$visibilityGenerator->next();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}));
|
||||||
$columnDimension = $this->getMockBuilder(ColumnDimension::class)
|
$columnDimension = $this->getMockBuilder(ColumnDimension::class)
|
||||||
->setMethods(['getVisible'])
|
->setMethods(['getVisible'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
@ -602,12 +611,16 @@ class MathTrigTest extends TestCase
|
||||||
return require 'data/Calculation/MathTrig/SUBTOTALHIDDEN.php';
|
return require 'data/Calculation/MathTrig/SUBTOTALHIDDEN.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function cellValues($cellValues) {
|
protected function cellValues(array $cellValues)
|
||||||
yield from $cellValues;
|
{
|
||||||
|
foreach ($cellValues as $k => $v) {
|
||||||
|
yield $k => $v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function cellIsFormula($cellValues) {
|
protected function cellIsFormula(array $cellValues)
|
||||||
foreach($cellValues as $cellValue) {
|
{
|
||||||
|
foreach ($cellValues as $cellValue) {
|
||||||
yield $cellValue[0] === '=';
|
yield $cellValue[0] === '=';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -627,9 +640,19 @@ class MathTrigTest extends TestCase
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$cell->method('getValue')
|
$cell->method('getValue')
|
||||||
->will($this->returnCallback(function() use ($cellValueGenerator) { $result = $cellValueGenerator->current(); $cellValueGenerator->next(); return $result; }));
|
->will($this->returnCallback(function () use ($cellValueGenerator) {
|
||||||
|
$result = $cellValueGenerator->current();
|
||||||
|
$cellValueGenerator->next();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}));
|
||||||
$cell->method('isFormula')
|
$cell->method('isFormula')
|
||||||
->will($this->returnCallback(function() use ($cellIsFormulaGenerator) { $result = $cellIsFormulaGenerator->current(); $cellIsFormulaGenerator->next(); return $result; }));
|
->will($this->returnCallback(function () use ($cellIsFormulaGenerator) {
|
||||||
|
$result = $cellIsFormulaGenerator->current();
|
||||||
|
$cellIsFormulaGenerator->next();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}));
|
||||||
$worksheet = $this->getMockBuilder(Worksheet::class)
|
$worksheet = $this->getMockBuilder(Worksheet::class)
|
||||||
->setMethods(['cellExists', 'getCell'])
|
->setMethods(['cellExists', 'getCell'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
|
|
@ -12,7 +12,7 @@ $baseTestData = [
|
||||||
9 => ['A' => 21],
|
9 => ['A' => 21],
|
||||||
10 => ['A' => 34],
|
10 => ['A' => 34],
|
||||||
11 => ['A' => 55],
|
11 => ['A' => 55],
|
||||||
12 => ['A' => 89]
|
12 => ['A' => 89],
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -12,7 +12,7 @@ $baseTestData = [
|
||||||
9 => ['A' => 21],
|
9 => ['A' => 21],
|
||||||
10 => ['A' => 34],
|
10 => ['A' => 34],
|
||||||
11 => ['A' => 55],
|
11 => ['A' => 55],
|
||||||
12 => ['A' => 89]
|
12 => ['A' => 89],
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
Loading…
Reference in New Issue