Passed
Pull Request — master (#4277)
by Owen
14:01
created

Biff8CoverTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 21
c 1
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 3 1
A testBiff8Coverage() 0 25 1
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xls;
4
5
use PhpOffice\PhpSpreadsheet\Reader\Xls;
6
use PhpOffice\PhpSpreadsheet\Shared\Date;
7
use PHPUnit\Framework\TestCase;
8
9
class Biff8CoverTest extends TestCase
10
{
11
    protected function tearDown(): void
12
    {
13
        Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
14
    }
15
16
    public function testBiff8Coverage(): void
17
    {
18
        $filename = 'tests/data/Reader/XLS/biff8cover.xls';
19
        $reader = new Xls();
20
        $spreadsheet = $reader->load($filename);
21
        $sheet = $spreadsheet->getActiveSheet();
22
        self::assertSame('=SUM({1;2;3;4;5})', $sheet->getCell('A1')->getValue());
23
        self::assertSame(15, $sheet->getCell('A1')->getCalculatedValue());
24
        self::assertSame(
25
            '=VLOOKUP("hello",'
26
            . '{"what",1;"why",TRUE;"hello","there";"when",FALSE}'
27
            . ',2,FALSE)',
28
            $sheet->getCell('C1')->getValue()
29
        );
30
        self::assertSame('there', $sheet->getCell('C1')->getCalculatedValue());
31
        self::assertSame(2, $sheet->getCell('A3')->getValue());
32
        self::assertTrue(
33
            $sheet->getStyle('A3')->getFont()->getSuperscript()
34
        );
35
        self::assertSame('n', $sheet->getCell('B3')->getValue());
36
        self::assertTrue(
37
            $sheet->getStyle('B3')->getFont()->getSubscript()
38
        );
39
40
        $spreadsheet->disconnectWorksheets();
41
    }
42
}
43