Failed Conditions
Push — master ( d2dc84...8e498d )
by Adrien
07:27
created

TransactionLinesTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 16
dl 0
loc 27
rs 10
c 1
b 0
f 0

1 Method

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