Passed
Push — master ( c380b2...9239b3 )
by Adrien
10:06
created

AllSetupTeardown::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
4
5
use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalcException;
6
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
7
use PhpOffice\PhpSpreadsheet\Spreadsheet;
8
use PHPUnit\Framework\TestCase;
9
10
class AllSetupTeardown extends TestCase
11
{
12
    protected $compatibilityMode;
13
14
    protected $spreadsheet;
15
16
    protected $sheet;
17
18
    protected function setUp(): void
19
    {
20
        $this->compatibilityMode = Functions::getCompatibilityMode();
21
        $this->spreadsheet = new Spreadsheet();
22
        $this->sheet = $this->spreadsheet->getActiveSheet();
23
    }
24
25
    protected function tearDown(): void
26
    {
27
        Functions::setCompatibilityMode($this->compatibilityMode);
28
        $this->spreadsheet->disconnectWorksheets();
29
        $this->spreadsheet = null;
30
        $this->sheet = null;
31
    }
32
33
    protected static function setOpenOffice(): void
34
    {
35
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE);
36
    }
37
38
    protected static function setGnumeric(): void
39
    {
40
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC);
41
    }
42
43
    /**
44
     * @param mixed $expectedResult
45
     */
46
    protected function mightHaveException($expectedResult): void
47
    {
48
        if ($expectedResult === 'exception') {
49
            $this->expectException(CalcException::class);
50
        }
51
    }
52
}
53