Completed
Push — develop ( 268fc1...a06731 )
by Adrien
23:59
created

CalculationTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testBinaryComparisonOperation() 0 10 1
A providerBinaryComparisonOperation() 0 4 1
A testGetFunctions() 0 4 1
A providerGetFunctions() 0 4 1
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests;
4
5
use PhpOffice\PhpSpreadsheet\Calculation;
6
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
7
8
class CalculationTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function setUp()
11
    {
12
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
13
    }
14
15
    /**
16
     * @dataProvider providerBinaryComparisonOperation
17
     */
18
    public function testBinaryComparisonOperation($formula, $expectedResultExcel, $expectedResultOpenOffice)
19
    {
20
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
21
        $resultExcel = Calculation::getInstance()->_calculateFormulaValue($formula);
22
        $this->assertEquals($expectedResultExcel, $resultExcel, 'should be Excel compatible');
23
24
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE);
25
        $resultOpenOffice = Calculation::getInstance()->_calculateFormulaValue($formula);
26
        $this->assertEquals($expectedResultOpenOffice, $resultOpenOffice, 'should be OpenOffice compatible');
27
    }
28
29
    public function providerBinaryComparisonOperation()
30
    {
31
        return require 'data/CalculationBinaryComparisonOperation.php';
32
    }
33
34
    /**
35
     * @dataProvider providerGetFunctions
36
     */
37
    public function testGetFunctions($category, $functionCall, $argumentCount)
0 ignored issues
show
Unused Code introduced by
The parameter $category is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $argumentCount is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39
        $this->assertTrue(is_callable($functionCall));
40
    }
41
42
    public function providerGetFunctions()
43
    {
44
        return Calculation::getInstance()->getFunctions();
45
    }
46
}
47