Skip to content

Commit

Permalink
Finish unit tests for spreadsheet documents.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentmuller committed Jun 17, 2024
1 parent 3676c9c commit 0f440a7
Show file tree
Hide file tree
Showing 11 changed files with 367 additions and 287 deletions.
2 changes: 1 addition & 1 deletion src/Service/DatabaseInfoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Service to get database information.
*/
final class DatabaseInfoService
class DatabaseInfoService
{
/** @var array<string, string>|null */
private ?array $configuration = null;
Expand Down
257 changes: 0 additions & 257 deletions src/Spreadsheet/CellBuilder.php

This file was deleted.

31 changes: 11 additions & 20 deletions src/Spreadsheet/PhpIniDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
*/
class PhpIniDocument extends AbstractDocument
{
private ?string $key = null;

/**
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
Expand Down Expand Up @@ -61,9 +59,7 @@ public function render(): bool

/** @psalm-var array<string, EntriesType> $entries */
foreach ($content as $key => $entries) {
if ($this->outputGroup($sheet, $row, $key)) {
++$row;
}
$row = $this->outputGroup($sheet, $row, $key);
$row = $this->outputEntries($sheet, $row, $entries);
}

Expand Down Expand Up @@ -149,23 +145,18 @@ private function outputEntries(WorksheetDocument $sheet, int $row, array $entrie
}

/**
* @throws \PhpOffice\PhpSpreadsheet\Exception if an error occurs
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
private function outputGroup(WorksheetDocument $sheet, int $row, string $group): bool
private function outputGroup(WorksheetDocument $sheet, int $row, string $group): int
{
if ($this->key !== $group) {
$sheet->setRowValues($row, [$group]);
$sheet->mergeContent(1, 3, $row);
$style = $sheet->getStyle("A$row");
$style->getFill()->setFillType(Fill::FILL_SOLID)
->getStartColor()->setARGB('F5F5F5');
$style->getFont()->setBold(true);
$this->key = $group;

return true;
}

return false;
$sheet->setRowValues($row, [$group]);
$sheet->mergeContent(1, 3, $row);
$style = $sheet->getStyle("A$row");
$style->getFill()->setFillType(Fill::FILL_SOLID)
->getStartColor()->setARGB('F5F5F5');
$style->getFont()->setBold(true);

return $row + 1;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions templates/calculation/calculation_ajax_totals.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{# groups #}
{% apply spaceless %}
{% for group in groups %}
<tr>
{% switch group.id %}
Expand Down Expand Up @@ -48,3 +49,4 @@
{% endswitch %}
</tr>
{% endfor %}
{% endapply %}
2 changes: 2 additions & 0 deletions tests/Command/UpdateAssetsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

namespace App\Tests\Command;

use App\Command\LoggerTrait;
use App\Command\UpdateAssetsCommand;
use PHPUnit\Framework\Attributes\CoversClass;

#[CoversClass(UpdateAssetsCommand::class)]
#[CoversClass(LoggerTrait::class)]
class UpdateAssetsCommandTest extends AbstractCommandTestCase
{
private const COMMAND_NAME = 'app:update-assets';
Expand Down
Loading

0 comments on commit 0f440a7

Please sign in to comment.