-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Additional unit tests
- Loading branch information
Mark Baker
authored
Mar 2, 2021
1 parent
2eaf9b5
commit 42e8680
Showing
14 changed files
with
271 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Functions; | ||
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ColumnTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); | ||
} | ||
|
||
/** | ||
* @dataProvider providerCOLUMN | ||
* | ||
* @param mixed $expectedResult | ||
*/ | ||
public function testCOLUMN($expectedResult, string $cellReference): void | ||
{ | ||
$result = LookupRef::COLUMN($cellReference); | ||
self::assertSame($expectedResult, $result); | ||
} | ||
|
||
public function providerCOLUMN() | ||
{ | ||
return require 'tests/data/Calculation/LookupRef/COLUMN.php'; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Functions; | ||
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class RowTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); | ||
} | ||
|
||
/** | ||
* @dataProvider providerROW | ||
* | ||
* @param mixed $expectedResult | ||
*/ | ||
public function testROW($expectedResult, string $cellReference): void | ||
{ | ||
$result = LookupRef::ROW($cellReference); | ||
self::assertSame($expectedResult, $result); | ||
} | ||
|
||
public function providerROW() | ||
{ | ||
return require 'tests/data/Calculation/LookupRef/ROW.php'; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SkewTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Functions; | ||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class SkewTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); | ||
} | ||
|
||
/** | ||
* @dataProvider providerSKEW | ||
* | ||
* @param mixed $expectedResult | ||
*/ | ||
public function testSKEW($expectedResult, array $args): void | ||
{ | ||
$result = Statistical::SKEW($args); | ||
self::assertEqualsWithDelta($expectedResult, $result, 1E-12); | ||
} | ||
|
||
public function providerSKEW() | ||
{ | ||
return require 'tests/data/Calculation/Statistical/SKEW.php'; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrimMeanTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Functions; | ||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class TrimMeanTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); | ||
} | ||
|
||
/** | ||
* @dataProvider providerTRIMMEAN | ||
* | ||
* @param mixed $expectedResult | ||
* @param mixed $percentage | ||
*/ | ||
public function testTRIMMEAN($expectedResult, array $args, $percentage): void | ||
{ | ||
$result = Statistical::TRIMMEAN($args, $percentage); | ||
self::assertEqualsWithDelta($expectedResult, $result, 1E-12); | ||
} | ||
|
||
public function providerTRIMMEAN() | ||
{ | ||
return require 'tests/data/Calculation/Statistical/TRIMMEAN.php'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
return [ | ||
[ | ||
2, | ||
'B13', | ||
], | ||
[ | ||
[2, 3, 4], | ||
'B2:D2', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
return [ | ||
[ | ||
10, | ||
'C10', | ||
], | ||
[ | ||
[[10], [11], [12]], | ||
'C10:C12', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
return [ | ||
[ | ||
0.359543071407, | ||
[3, 4, 5, 2, 3, 4, 5, 6, 4, 7], | ||
], | ||
[ | ||
0.863378312234, | ||
[1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6, 7, 8], | ||
], | ||
[ | ||
'#VALUE!', | ||
[1, 1, 2, 2, 2, 2, 3, 'NaN', 3, 4, 4, 5, 6, 7, 8], | ||
], | ||
[ | ||
'#DIV/0!', | ||
[1, 1], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,4 +65,14 @@ | |
4, | ||
], | ||
], | ||
[ | ||
'#N/A', | ||
[1, 2, 3], | ||
[4, 5], | ||
], | ||
[ | ||
'#DIV/0!', | ||
[1, 2, 3], | ||
[4, null, null], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
return [ | ||
[ | ||
3.777777777778, | ||
[4, 5, 6, 7, 2, 3, 4, 5, 1, 2, 3], | ||
0.2, | ||
], | ||
[ | ||
9.45, | ||
[0.5, 6, 7, 7, 8, 8, 9, 9, 16, 24], | ||
0.15, | ||
], | ||
[ | ||
8.75, | ||
[0.5, 6, 7, 7, 8, 8, 9, 9, 16, 24], | ||
0.2, | ||
], | ||
[ | ||
8.0, | ||
[0.5, 6, 7, 7, 8, 8, 9, 9, 16, 24], | ||
0.4, | ||
], | ||
[ | ||
'#NUM!', | ||
[0.5, 6, 7, 7, 8, 8, 9, 9, 16, 24], | ||
15, | ||
], | ||
[ | ||
'#VALUE!', | ||
[0.5, 6, 7, 7, 8, 8, 9, 9, 16, 24], | ||
'NaN', | ||
], | ||
]; |