Skip to content

Commit c84bdbf

Browse files
committed
Add Test Case
1 parent d0e8c03 commit c84bdbf

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpOffice\PhpSpreadsheetTests\Style\ConditionalFormatting;
6+
7+
use PhpOffice\PhpSpreadsheet\Spreadsheet;
8+
use PhpOffice\PhpSpreadsheet\Style\Conditional;
9+
use PhpOffice\PhpSpreadsheet\Style\Fill;
10+
use PhpOffice\PhpSpreadsheet\Style\Style;
11+
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as XlsxWriter;
12+
use PHPUnit\Framework\TestCase;
13+
14+
class PR3946Test extends TestCase
15+
{
16+
public function testConditionalTextInitialized(): void
17+
{
18+
$spreadsheet = new Spreadsheet();
19+
$sheet = $spreadsheet->getActiveSheet();
20+
21+
$cellRange = 'C3:E5';
22+
$style = new Style();
23+
$style->applyFromArray([
24+
'fill' => [
25+
'color' => ['argb' => 'FFFFC000'],
26+
'fillType' => Fill::FILL_SOLID,
27+
],
28+
]);
29+
30+
$condition = new Conditional();
31+
$condition->setConditionType(Conditional::CONDITION_CONTAINSTEXT);
32+
$condition->setOperatorType(Conditional::OPERATOR_CONTAINSTEXT);
33+
$condition->setStyle($style);
34+
$sheet->setConditionalStyles($cellRange, [$condition]);
35+
36+
$writer = new XlsxWriter($spreadsheet);
37+
38+
$writerWorksheet = new XlsxWriter\Worksheet($writer);
39+
$data = $writerWorksheet->writeWorksheet($sheet, []);
40+
self::assertStringContainsString('<conditionalFormatting sqref="C3:E5">', $data);
41+
}
42+
}

0 commit comments

Comments
 (0)