0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-04-19 11:39:48 +00:00
kevinpapst_kimai2/tests/Export/Package/SpoutSpreadsheetTest.php
Kevin Papst b42c77a2a1
Release 2.29 (#5325)
* bump composer packages
* fixes #5329 quotes for ANSI_MODE
* improve year selection
* improve year selection via dropdown
* added range selector in month-picker
* fix week number if week starts with sunday
* fix first day of month in URL
* predefined options for week chooser
* z-index issue with sticky table header
* replace duplicated translations
* add logout button to allow user switch without having to re-login in "remember me" login
* new flag to detect if invoice entry is a fixed rate
* improve export column lengths
2025-02-09 00:16:03 +01:00

53 lines
1.6 KiB
PHP

<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Export\Package;
use App\Export\Package\CellFormatter\DefaultFormatter;
use App\Export\Package\Column;
use App\Export\Package\SpoutSpreadsheet;
use OpenSpout\Writer\CSV\Writer;
use PHPUnit\Framework\TestCase;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @covers \App\Export\Package\SpoutSpreadsheet
*/
class SpoutSpreadsheetTest extends TestCase
{
private string $filename;
private int $counter = 1;
protected function setUp(): void
{
$this->filename = realpath(__DIR__ . '/../../_data/') . '/test' . $this->counter++ . '.xlsx';
}
protected function tearDown(): void
{
if (file_exists($this->filename)) {
unlink($this->filename);
}
}
public function testsaveWritesFile(): void
{
$translator = $this->createMock(TranslatorInterface::class);
$translator->method('trans')->willReturnArgument(0);
$spreadsheetPackage = new SpoutSpreadsheet(new Writer(), $translator);
$spreadsheetPackage->open($this->filename);
$spreadsheetPackage->setColumns([new Column('Foo', new DefaultFormatter()), new Column('Bar', new DefaultFormatter())]);
$spreadsheetPackage->addRow(['Data1', 'Data2']);
$spreadsheetPackage->addRow(['Data3', 'Data4']);
$spreadsheetPackage->save();
self::assertGreaterThan(0, filesize($this->filename));
}
}