Add Hidden Worksheet unit tests for other Readers
This commit is contained in:
parent
23ce21901d
commit
bb7e083745
|
|
@ -16,7 +16,7 @@
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>XLS</th>
|
<th>XLS</th>
|
||||||
<th>XLSX</th>
|
<th>XLSX</th>
|
||||||
<th>Excel2003XML</th>
|
<th>XML (Excel2003XML)</th>
|
||||||
<th>Ods</th>
|
<th>Ods</th>
|
||||||
<th>Gnumeric</th>
|
<th>Gnumeric</th>
|
||||||
<th>CSV</th>
|
<th>CSV</th>
|
||||||
|
|
@ -732,12 +732,32 @@
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-left: 1em;">Hidden Worksheets</td>
|
||||||
|
<td style="text-align: center; color: green;">✔</td>
|
||||||
|
<td style="text-align: center; color: green;">✔</td>
|
||||||
|
<td></td>
|
||||||
|
<td style="text-align: center; color: green;">✔</td>
|
||||||
|
<td style="text-align: center; color: green;">✔</td>
|
||||||
|
<td style="text-align: center;">N/A</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 1em;">Coloured Tabs</td>
|
<td style="padding-left: 1em;">Coloured Tabs</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
<td></td>
|
||||||
<td style="text-align: center;">N/A</td>
|
<td style="text-align: center;">N/A</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ class HiddenWorksheetTest extends TestCase
|
||||||
|
|
||||||
$sheetAssertions = $assertions[$worksheet->getTitle()];
|
$sheetAssertions = $assertions[$worksheet->getTitle()];
|
||||||
foreach ($sheetAssertions as $test => $expectedResult) {
|
foreach ($sheetAssertions as $test => $expectedResult) {
|
||||||
$testMethodName = 'get' . ucfirst($test);
|
|
||||||
$actualResult = $worksheet->getSheetState();
|
$actualResult = $worksheet->getSheetState();
|
||||||
self::assertSame(
|
self::assertSame(
|
||||||
$expectedResult,
|
$expectedResult,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xls;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Reader\Xls;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class HiddenWorksheetTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Spreadsheet
|
||||||
|
*/
|
||||||
|
private $spreadsheet;
|
||||||
|
|
||||||
|
protected function setup(): void
|
||||||
|
{
|
||||||
|
$filename = 'tests/data/Reader/XLS/HiddenSheet.xls';
|
||||||
|
$reader = new Xls();
|
||||||
|
$this->spreadsheet = $reader->load($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPageSetup(): void
|
||||||
|
{
|
||||||
|
$assertions = $this->worksheetAssertions();
|
||||||
|
|
||||||
|
foreach ($this->spreadsheet->getAllSheets() as $worksheet) {
|
||||||
|
if (!array_key_exists($worksheet->getTitle(), $assertions)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sheetAssertions = $assertions[$worksheet->getTitle()];
|
||||||
|
foreach ($sheetAssertions as $test => $expectedResult) {
|
||||||
|
$actualResult = $worksheet->getSheetState();
|
||||||
|
self::assertSame(
|
||||||
|
$expectedResult,
|
||||||
|
$actualResult,
|
||||||
|
"Failed asserting sheet state {$expectedResult} for Worksheet '{$worksheet->getTitle()}' {$test}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function worksheetAssertions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Sheet1' => [
|
||||||
|
'sheetState' => Worksheet::SHEETSTATE_VISIBLE,
|
||||||
|
],
|
||||||
|
'Sheet2' => [
|
||||||
|
'sheetState' => Worksheet::SHEETSTATE_HIDDEN,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class HiddenWorksheetTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Spreadsheet
|
||||||
|
*/
|
||||||
|
private $spreadsheet;
|
||||||
|
|
||||||
|
protected function setup(): void
|
||||||
|
{
|
||||||
|
$filename = 'tests/data/Reader/XLSX/HiddenSheet.xlsx';
|
||||||
|
$reader = new Xlsx();
|
||||||
|
$this->spreadsheet = $reader->load($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPageSetup(): void
|
||||||
|
{
|
||||||
|
$assertions = $this->worksheetAssertions();
|
||||||
|
|
||||||
|
foreach ($this->spreadsheet->getAllSheets() as $worksheet) {
|
||||||
|
if (!array_key_exists($worksheet->getTitle(), $assertions)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sheetAssertions = $assertions[$worksheet->getTitle()];
|
||||||
|
foreach ($sheetAssertions as $test => $expectedResult) {
|
||||||
|
$actualResult = $worksheet->getSheetState();
|
||||||
|
self::assertSame(
|
||||||
|
$expectedResult,
|
||||||
|
$actualResult,
|
||||||
|
"Failed asserting sheet state {$expectedResult} for Worksheet '{$worksheet->getTitle()}' {$test}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function worksheetAssertions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Sheet1' => [
|
||||||
|
'sheetState' => Worksheet::SHEETSTATE_VISIBLE,
|
||||||
|
],
|
||||||
|
'Sheet2' => [
|
||||||
|
'sheetState' => Worksheet::SHEETSTATE_HIDDEN,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue