1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation; |
4
|
|
|
|
5
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Functions; |
6
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Logical; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
class LogicalTest extends TestCase |
10
|
|
|
{ |
11
|
|
|
public function setUp() |
12
|
|
|
{ |
13
|
|
|
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
public function testTRUE() |
17
|
|
|
{ |
18
|
|
|
$result = Logical::TRUE(); |
19
|
|
|
self::assertTrue($result); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function testFALSE() |
23
|
|
|
{ |
24
|
|
|
$result = Logical::FALSE(); |
25
|
|
|
self::assertFalse($result); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @dataProvider providerAND |
30
|
|
|
* |
31
|
|
|
* @param mixed $expectedResult |
32
|
|
|
*/ |
33
|
|
|
public function testAND($expectedResult, ...$args) |
34
|
|
|
{ |
35
|
|
|
$result = Logical::logicalAnd(...$args); |
36
|
|
|
self::assertEquals($expectedResult, $result); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function providerAND() |
40
|
|
|
{ |
41
|
|
|
return require 'data/Calculation/Logical/AND.php'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @dataProvider providerOR |
46
|
|
|
* |
47
|
|
|
* @param mixed $expectedResult |
48
|
|
|
*/ |
49
|
|
|
public function testOR($expectedResult, ...$args) |
50
|
|
|
{ |
51
|
|
|
$result = Logical::logicalOr(...$args); |
52
|
|
|
self::assertEquals($expectedResult, $result); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function providerOR() |
56
|
|
|
{ |
57
|
|
|
return require 'data/Calculation/Logical/OR.php'; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @dataProvider providerXOR |
62
|
|
|
* |
63
|
|
|
* @param mixed $expectedResult |
64
|
|
|
*/ |
65
|
|
|
public function testXOR($expectedResult, ...$args) |
66
|
|
|
{ |
67
|
|
|
$result = Logical::logicalXor(...$args); |
68
|
|
|
self::assertEquals($expectedResult, $result); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function providerXOR() |
72
|
|
|
{ |
73
|
|
|
return require 'data/Calculation/Logical/XOR.php'; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @dataProvider providerNOT |
78
|
|
|
* |
79
|
|
|
* @param mixed $expectedResult |
80
|
|
|
*/ |
81
|
|
|
public function testNOT($expectedResult, ...$args) |
82
|
|
|
{ |
83
|
|
|
$result = Logical::NOT(...$args); |
|
|
|
|
84
|
|
|
self::assertEquals($expectedResult, $result); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function providerNOT() |
88
|
|
|
{ |
89
|
|
|
return require 'data/Calculation/Logical/NOT.php'; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @dataProvider providerIF |
94
|
|
|
* |
95
|
|
|
* @param mixed $expectedResult |
96
|
|
|
*/ |
97
|
|
|
public function testIF($expectedResult, ...$args) |
98
|
|
|
{ |
99
|
|
|
$result = Logical::statementIf(...$args); |
|
|
|
|
100
|
|
|
self::assertEquals($expectedResult, $result); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function providerIF() |
104
|
|
|
{ |
105
|
|
|
return require 'data/Calculation/Logical/IF.php'; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @dataProvider providerIFERROR |
110
|
|
|
* |
111
|
|
|
* @param mixed $expectedResult |
112
|
|
|
*/ |
113
|
|
|
public function testIFERROR($expectedResult, ...$args) |
114
|
|
|
{ |
115
|
|
|
$result = Logical::IFERROR(...$args); |
|
|
|
|
116
|
|
|
self::assertEquals($expectedResult, $result); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function providerIFERROR() |
120
|
|
|
{ |
121
|
|
|
return require 'data/Calculation/Logical/IFERROR.php'; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|