mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-17 12:21:50 +00:00
Add Test Case
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Style\ConditionalFormatting;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Conditional;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Style;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as XlsxWriter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PR3946Test extends TestCase
|
||||
{
|
||||
public function testConditionalTextInitialized(): void
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$cellRange = 'C3:E5';
|
||||
$style = new Style();
|
||||
$style->applyFromArray([
|
||||
'fill' => [
|
||||
'color' => ['argb' => 'FFFFC000'],
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
],
|
||||
]);
|
||||
|
||||
$condition = new Conditional();
|
||||
$condition->setConditionType(Conditional::CONDITION_CONTAINSTEXT);
|
||||
$condition->setOperatorType(Conditional::OPERATOR_CONTAINSTEXT);
|
||||
$condition->setStyle($style);
|
||||
$sheet->setConditionalStyles($cellRange, [$condition]);
|
||||
|
||||
$writer = new XlsxWriter($spreadsheet);
|
||||
|
||||
$writerWorksheet = new XlsxWriter\Worksheet($writer);
|
||||
$data = $writerWorksheet->writeWorksheet($sheet, []);
|
||||
self::assertStringContainsString('<conditionalFormatting sqref="C3:E5">', $data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user