Completed
Push — develop ( a045a4...56245d )
by Adrien
17:07
created

providerBinaryComparisonOperation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
     * @param mixed $formula
19
     * @param mixed $expectedResultExcel
20
     * @param mixed $expectedResultOpenOffice
21
     */
22
    public function testBinaryComparisonOperation($formula, $expectedResultExcel, $expectedResultOpenOffice)
23
    {
24
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
25
        $resultExcel = Calculation::getInstance()->_calculateFormulaValue($formula);
26
        $this->assertEquals($expectedResultExcel, $resultExcel, 'should be Excel compatible');
27
28
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE);
29
        $resultOpenOffice = Calculation::getInstance()->_calculateFormulaValue($formula);
30
        $this->assertEquals($expectedResultOpenOffice, $resultOpenOffice, 'should be OpenOffice compatible');
31
    }
32
33
    public function providerBinaryComparisonOperation()
34
    {
35
        return require 'data/CalculationBinaryComparisonOperation.php';
36
    }
37
38
    /**
39
     * @dataProvider providerGetFunctions
40
     *
41
     * @param mixed $category
42
     * @param mixed $functionCall
43
     * @param mixed $argumentCount
44
     */
45
    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...
46
    {
47
        $this->assertInternalType('callable', $functionCall);
48
    }
49
50
    public function providerGetFunctions()
51
    {
52
        return Calculation::getInstance()->getFunctions();
53
    }
54
55
    public function testIsImplemented()
56
    {
57
        $calculation = Calculation::getInstance();
58
        $this->assertFalse($calculation->isImplemented('non-existing-function'));
59
        $this->assertFalse($calculation->isImplemented('AREAS'));
60
        $this->assertTrue($calculation->isImplemented('coUNt'));
61
        $this->assertTrue($calculation->isImplemented('abs'));
62
    }
63
}
64