mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-27 10:30:02 +00:00
83c0f02c95
PR #2088 is having major merge problems. This is partly because it moves some tests from Reader to Reader/Xlsx. Making this move beforehand may help. Or it may make things worse, but they are already bad enough that I am contemplating redoing the PR. If I do that, having this done beforehand will make things easier. This PR does nothing but move some tests. This will make it easier to test changes to Xlsx Reader without having to run each test individually, or without having to run tests for all the other readers at the same time.
40 lines
1.7 KiB
PHP
40 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
|
use PhpOffice\PhpSpreadsheet\Style\Conditional;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class CondNumFmtTest extends TestCase
|
|
{
|
|
public function testLoadCondNumFmt(): void
|
|
{
|
|
$filename = 'tests/data/Reader/XLSX/condfmtnum.xlsx';
|
|
$reader = new Xlsx();
|
|
$spreadsheet = $reader->load($filename);
|
|
|
|
$worksheet = $spreadsheet->getActiveSheet();
|
|
// NumberFormat explicitly set in following conditional style
|
|
$conditionalStyle = $worksheet->getConditionalStyles('A1:A3');
|
|
self::assertNotEmpty($conditionalStyle);
|
|
$conditionalRule = $conditionalStyle[0];
|
|
$conditions = $conditionalRule->getConditions();
|
|
self::assertNotEmpty($conditions);
|
|
self::assertEquals(Conditional::CONDITION_EXPRESSION, $conditionalRule->getConditionType());
|
|
self::assertEquals('MONTH(A1)=10', $conditions[0]);
|
|
$numfmt = $conditionalRule->getStyle()->getNumberFormat()->getFormatCode();
|
|
self::assertEquals('yyyy/mm/dd', $numfmt);
|
|
// NumberFormat not set in following conditional style
|
|
$conditionalStyle = $worksheet->getConditionalStyles('B1');
|
|
self::assertNotEmpty($conditionalStyle);
|
|
$conditionalRule = $conditionalStyle[0];
|
|
$conditions = $conditionalRule->getConditions();
|
|
self::assertNotEmpty($conditions);
|
|
self::assertEquals(Conditional::CONDITION_EXPRESSION, $conditionalRule->getConditionType());
|
|
self::assertEquals('AND(B1>=2000,B1<3000)', $conditions[0]);
|
|
$numfmt = $conditionalRule->getStyle()->getNumberFormat()->getFormatCode();
|
|
self::assertEquals('', $numfmt);
|
|
}
|
|
}
|