Passed
Push — master ( b9ca8a...ef997a )
by Adrien
09:41
created

FontTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 30
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSuperSubScript() 0 31 1
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Style;
4
5
use PhpOffice\PhpSpreadsheet\Spreadsheet;
6
use PHPUnit\Framework\TestCase;
7
8
class FontTest extends TestCase
9
{
10
    public function testSuperSubScript(): void
11
    {
12
        $spreadsheet = new Spreadsheet();
13
        $sheet = $spreadsheet->getActiveSheet();
14
        $cell = $sheet->getCell('A1');
15
        $cell->setValue('Cell A1');
16
        $font = $cell->getStyle()->getFont();
17
        $font->setSuperscript(true);
18
        $font->setSubscript(true);
19
        self::assertFalse($font->getSuperscript(), 'Earlier set true loses');
20
        self::assertTrue($font->getSubscript(), 'Last set true wins');
21
        $font->setSubscript(true);
22
        $font->setSuperscript(true);
23
        self::assertTrue($font->getSuperscript(), 'Last set true wins');
24
        self::assertFalse($font->getSubscript(), 'Earlier set true loses');
25
        $font->setSuperscript(false);
26
        $font->setSubscript(false);
27
        self::assertFalse($font->getSuperscript(), 'False remains unchanged');
28
        self::assertFalse($font->getSubscript(), 'False remains unchanged');
29
        $font->setSubscript(false);
30
        $font->setSuperscript(false);
31
        self::assertFalse($font->getSuperscript(), 'False remains unchanged');
32
        self::assertFalse($font->getSubscript(), 'False remains unchanged');
33
        $font->setSubscript(true);
34
        $font->setSuperscript(false);
35
        self::assertFalse($font->getSuperscript(), 'False remains unchanged');
36
        self::assertTrue($font->getSubscript(), 'True remains unchanged');
37
        $font->setSubscript(false);
38
        $font->setSuperscript(true);
39
        self::assertTrue($font->getSuperscript());
40
        self::assertFalse($font->getSubscript(), 'False remains unchanged');
41
    }
42
}
43