Completed
Push — master ( 58c6e5...dcb10e )
by Mark
46s queued 34s
created

testLoadingConditionalDoesntLoseSelectedCell()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
4
5
use PhpOffice\PhpSpreadsheet\IOFactory;
6
use PhpOffice\PhpSpreadsheet\Style\Conditional;
7
use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional;
8
9
class ConditionalTest extends AbstractFunctional
10
{
11
    public function testLoadingConditionalDoesntLoseSelectedCell(): void
12
    {
13
        $filename = 'tests/data/Reader/XLSX/ConditionalFormat_Ranges.xlsx';
14
        $reader = IOFactory::createReader('Xlsx');
15
        $spreadsheet = $reader->load($filename);
16
        $worksheet = $spreadsheet->getActiveSheet();
17
18
        self::assertSame('A1', $worksheet->getActiveCell());
19
        self::assertSame('A1', $worksheet->getSelectedCells());
20
    }
21
22
    /**
23
     * Test check if conditional style with type 'notContainsText' works on xlsx.
24
     */
25
    public function testConditionalNotContainsText(): void
26
    {
27
        $filename = 'tests/data/Reader/XLSX/conditionalFormatting3Test.xlsx';
28
        $reader = IOFactory::createReader('Xlsx');
29
        $spreadsheet = $reader->load($filename);
30
        $worksheet = $spreadsheet->getActiveSheet();
31
        $styles = $worksheet->getConditionalStyles('A1:A5');
32
33
        self::assertCount(1, $styles);
34
35
        /** @var Conditional $notContainsTextStyle */
36
        $notContainsTextStyle = $styles[0];
37
        self::assertEquals('A', $notContainsTextStyle->getText());
38
        self::assertEquals(Conditional::CONDITION_NOTCONTAINSTEXT, $notContainsTextStyle->getConditionType());
39
        self::assertEquals(Conditional::OPERATOR_NOTCONTAINS, $notContainsTextStyle->getOperatorType());
40
    }
41
}
42