mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 16:19:19 +00:00
ec4098c8fd
While we might never be able to have 100% of our code strict, we can at the very least do it for all of our tests. This ensures that our tests are using our API with the types as intended by the test author, and not silently be cast to what our API requires.
46 lines
1.7 KiB
PHP
46 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class DefaultFillTest extends TestCase
|
|
{
|
|
public function testDefaultFill(): void
|
|
{
|
|
// default fill pattern doesn't specify filltype
|
|
$filename = 'tests/data/Reader/XLSX/pr1769g.py.xlsx';
|
|
$file = 'zip://';
|
|
$file .= $filename;
|
|
$file .= '#xl/styles.xml';
|
|
$data = file_get_contents($file);
|
|
// confirm that file contains expected empty xml tag
|
|
if ($data === false) {
|
|
self::fail('Unable to read file');
|
|
} else {
|
|
self::assertStringContainsString('<patternFill/>', $data);
|
|
}
|
|
$reader = IOFactory::createReader('Xlsx');
|
|
$spreadsheet = $reader->load($filename);
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
self::assertSame('none', $sheet->getCell('A1')->getStyle()->getFill()->getFillType());
|
|
self::assertSame('none', $sheet->getCell('D4')->getStyle()->getFill()->getFillType());
|
|
self::assertSame('none', $sheet->getCell('J16')->getStyle()->getFill()->getFillType());
|
|
self::assertSame('solid', $sheet->getCell('C2')->getStyle()->getFill()->getFillType());
|
|
}
|
|
|
|
public function testDefaultConditionalFill(): void
|
|
{
|
|
// default fill pattern for a conditional style where the filltype is not defined
|
|
$filename = 'tests/data/Reader/XLSX/pr2050cf-fill.xlsx';
|
|
$reader = IOFactory::createReader('Xlsx');
|
|
$spreadsheet = $reader->load($filename);
|
|
|
|
$style = $spreadsheet->getActiveSheet()->getConditionalStyles('A1')[0]->getStyle();
|
|
self::assertSame('solid', $style->getFill()->getFillType());
|
|
}
|
|
}
|