PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/StatisticalTest.php
Zdeněk Drahoš 42fc71f314 Calculation/Statistical :: Add MAXIFS, MINIFS, COUNTIFS and Remove MINIF, MAXIF (#1059)
* #1056 - replace invalid minif/maxif functions by not implemented minifs/maxifs

minif/maxif is not support in Excel, Google Spreadsheets, Libreoffice
https://support.office.com/en-us/article/excel-functions-alphabetical-b3944572-255d-4efb-bb96-c6d90033e188#bm13

* #1056 - implement minifs/maxifs

Copy-pasted sumifs...
https://github.com/PHPOffice/PhpSpreadsheet/blob/1.8.1/src/PhpSpreadsheet/Calculation/MathTrig.php#L1254

* #1056 - implement countifs

* #1056 - fix code style

composer check
composer fix

* #1056 - update changelog
2019-07-14 12:55:42 +02:00

64 lines
1.5 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PHPUnit\Framework\TestCase;
class StatisticalTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
}
/**
* @dataProvider providerCOUNTIFS
*
* @param mixed $expectedResult
*/
public function testCOUNTIFS($expectedResult, ...$args)
{
$result = Statistical::COUNTIFS(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12);
}
public function providerCOUNTIFS()
{
return require 'data/Calculation/Statistical/COUNTIFS.php';
}
/**
* @dataProvider providerMAXIFS
*
* @param mixed $expectedResult
*/
public function testMAXIFS($expectedResult, ...$args)
{
$result = Statistical::MAXIFS(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12);
}
public function providerMAXIFS()
{
return require 'data/Calculation/Statistical/MAXIFS.php';
}
/**
* @dataProvider providerMINIFS
*
* @param mixed $expectedResult
*/
public function testMINIFS($expectedResult, ...$args)
{
$result = Statistical::MINIFS(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12);
}
public function providerMINIFS()
{
return require 'data/Calculation/Statistical/MINIFS.php';
}
}