TransactionLinesTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 15
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testExportTransactionLines() 0 20 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApplicationTest\Service\Exporter;
6
7
use Application\Model\TransactionLine;
8
use Application\Service\Exporter\TransactionLines;
9
use ApplicationTest\Traits\TestWithSpreadsheet;
10
use ApplicationTest\Traits\TestWithTransactionAndUser;
11
use PHPUnit\Framework\TestCase;
12
13
class TransactionLinesTest extends TestCase
14
{
15
    use TestWithSpreadsheet;
16
    use TestWithTransactionAndUser;
17
18
    public function testExportTransactionLines(): void
19
    {
20
        $this->setCurrentUser('responsible');
21
22
        // Query to generate the Excel file on disk
23
        $hostname = 'my-ichtus.lan';
24
        $qb = _em()->getRepository(TransactionLine::class)->createQueryBuilder('tl');
25
        $handler = new TransactionLines($hostname);
26
        $result = $qb->getQuery()->getResult();
27
28
        $url = $handler->export($result);
29
30
        $spreadsheet = $this->readExport($hostname, $url);
31
        $sheet = $spreadsheet->getActiveSheet();
32
33
        // Test a few arbitrary data
34
        self::assertSame('Date', $sheet->getCell('A1')->getCalculatedValue());
35
        self::assertSame('Pointé', $sheet->getCell('M1')->getCalculatedValue());
36
        self::assertSame('Inscription cours nautique Active Member', $sheet->getCell('C2')->getCalculatedValue());
37
        self::assertSame(45562.5, $sheet->getCell('L14')->getCalculatedValue());
38
    }
39
}
40