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

CountATest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A providerCOUNTA() 0 3 1
A testNull() 0 11 1
A testCOUNTA() 0 4 1
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