|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx; |
| 6 | + |
| 7 | +use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader; |
| 8 | +use PHPUnit\Framework\TestCase; |
| 9 | + |
| 10 | +class Issue4629Test extends TestCase |
| 11 | +{ |
| 12 | + public function testExternalAndInternalCondionalStyles(): void |
| 13 | + { |
| 14 | + $infile = 'tests/data/Reader/XLSX/issue.4629.xlsx'; |
| 15 | + $reader = new XlsxReader(); |
| 16 | + $spreadsheet = $reader->load($infile); |
| 17 | + $sheet = $spreadsheet->getSheetByNameOrThrow('top'); |
| 18 | + $conditionals = $sheet->getStyle('A1:A20')->getConditionalStyles(); |
| 19 | + self::assertCount(3, $conditionals); |
| 20 | + |
| 21 | + $conditional = $conditionals[0]; |
| 22 | + self::assertSame('expression', $conditional->getConditionType()); |
| 23 | + self::assertFalse($conditional->getStopIfTrue()); |
| 24 | + self::assertSame(['$A1<>$B1'], $conditional->getConditions()); |
| 25 | + self::assertSame(2, $conditional->getPriority()); |
| 26 | + |
| 27 | + $conditional = $conditionals[1]; |
| 28 | + self::assertSame('expression', $conditional->getConditionType()); |
| 29 | + self::assertFalse($conditional->getStopIfTrue()); |
| 30 | + self::assertSame(['AND($A1="cheese", $C1="yogurt")'], $conditional->getConditions()); |
| 31 | + self::assertSame(3, $conditional->getPriority()); |
| 32 | + |
| 33 | + $conditional = $conditionals[2]; // defined within <ext> |
| 34 | + self::assertSame('expression', $conditional->getConditionType()); |
| 35 | + self::assertTrue($conditional->getStopIfTrue()); |
| 36 | + self::assertSame(['A1<>bottom!A1'], $conditional->getConditions()); |
| 37 | + self::assertSame(1, $conditional->getPriority()); |
| 38 | + self::assertSame('FF9C5700', $conditional->getStyle()->getFont()->getColor()->getArgb()); |
| 39 | + |
| 40 | + $spreadsheet->disconnectWorksheets(); |
| 41 | + } |
| 42 | +} |
0 commit comments