Passed
Push — master ( 35030f...e9f03d )
by
unknown
11:57 queued 56s
created

PR3946Test::testConditionalTextInitialized()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 25
rs 9.7
cc 1
nc 1
nop 0
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
}
43