Failed Conditions
Push — master ( ea97af...216db0 )
by
unknown
15:51 queued 07:40
created

CountATest::testNull()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 11
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
6
7
use PhpOffice\PhpSpreadsheet\Spreadsheet;
8
9
class CountATest extends AllSetupTeardown
10
{
11
    #[\PHPUnit\Framework\Attributes\DataProvider('providerCOUNTA')]
12
    public function testCOUNTA(mixed $expectedResult, mixed ...$args): void
13
    {
14
        $this->runTestCases('COUNTA', $expectedResult, ...$args);
15
    }
16
17
    public static function providerCOUNTA(): array
18
    {
19
        return require 'tests/data/Calculation/Statistical/COUNTA.php';
20
    }
21
22
    public function testNull(): void
23
    {
24
        $spreadsheet = new Spreadsheet();
25
        $sheet = $spreadsheet->getActiveSheet();
26
        $sheet->setCellValue('A1', '=COUNTA(B1,B2,B3,B4)');
27
        $sheet->setCellValue('A2', '=COUNTA(B1,,B3,B4)');
28
        $sheet->setCellValue('A3', '=COUNTA(B1,B2,B3,B4)');
29
        self::assertSame(0, $sheet->getCell('A1')->getCalculatedValue(), 'empty cells not counted');
30
        self::assertSame(1, $sheet->getCell('A2')->getCalculatedValue(), 'null argument is counted');
31
        self::assertSame(0, $sheet->getCell('A3')->getCalculatedValue(), 'empty cells still not counted');
32
        $spreadsheet->disconnectWorksheets();
33
    }
34
}
35