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

AllSetupTeardown   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setGnumeric() 0 3 1
A setOpenOffice() 0 3 1
A tearDown() 0 6 1
A mightHaveException() 0 4 2
A setUp() 0 5 1
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