Files
PhpSpreadsheet/tests/data/Calculation/Statistical/COUNTIF.php
T
oleibman 057572ee90 Change Additional Statistical Tests to Use Spreadsheet Context (#3217)
* Change Additional Statistical Tests to Use Spreadsheet Context

With an earlier change, I made all but 18 Statistical tests run in spreadsheet context. This PR changes 12 of those 18. The remaining 6 usually return array results, so it is a tougher task to handle them. I will continue to think on it.

AVERAGEIF, AVERAGEIFS, and COUNTBLANK are changed to throw an Exception when a range is specified as a literal. They previously accepted array (enclosed in braces) literals, and bumbled along till they threw an error for non-array literals. Throwing an exception appears to be analogous to how Excel operates, rather than something more friendly like a VALUE error. There may be other functions which require similar treatment.

There also remains a TODO for COUNTIFS, and possibly other functions. It appears that PhpSpreadsheet counts booleans for both integer and string compares and probably shouldn't. Again, this is a problem for another day.

* Scrutinizer

Fix one problem.

* Scrutinizer Ignores Its Own Suggested Remedy

Try another approach.
2022-12-02 14:14:43 -08:00

70 lines
1.2 KiB
PHP

<?php
return [
[
2,
['apples', 'oranges', 'peaches', 'apples'],
'apples',
],
[
2,
['ApPlEs', 'oranges', 'peaches', 'APPles'],
'aPpLeS',
],
[
2,
[32, 54, 75, 86],
'>55',
],
[
3,
[32, 54, 75, 86],
'<=75',
],
[
2,
[6, 3, 4, 'X', '', null],
'<=4',
],
[
2,
[6, 3, 4, 31, 'X', '', null],
'<="4"',
],
[
2,
[0, 1, 1, 2, 3, 5, 8, 0, 13, 21],
0,
],
[
3,
[true, false, false, true, false, true, false, false],
true,
],
[
5,
[true, false, false, true, false, true, false, false],
'<>true',
],
[
4,
['apples', 'oranges', 'peaches', 'apples'],
'*',
],
[
3,
['apples', 'oranges', 'peaches', 'apples'],
'*p*s*',
],
[
2,
['apples', 'oranges', 'peaches', 'apples'],
'?????es',
],
[
2,
['great * ratings', 'bad * ratings', 'films * wars', 'films * trek', 'music * radio'],
'*~* ra*s',
],
];