faster spreadsheet exporter based on opensout and other export improvements (#5238)

This commit is contained in:
Kevin Papst
2024-12-22 18:36:47 +01:00
committed by GitHub
parent c7f0508707
commit 136104d4b0
80 changed files with 2023 additions and 1699 deletions

View File

@@ -12,6 +12,7 @@ namespace App\Tests\Controller\Reporting;
use App\Entity\User;
use App\Tests\Controller\AbstractControllerBaseTestCase;
use App\Tests\DataFixtures\TimesheetFixtures;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
/**
* @group integration
@@ -30,6 +31,8 @@ abstract class AbstractUserPeriodControllerTestCase extends AbstractControllerBa
abstract protected function getReportUrl(): string;
abstract protected function getExportUrl(): string;
abstract protected function getBoxId(): string;
public function testIsSecure(): void
@@ -61,6 +64,31 @@ abstract class AbstractUserPeriodControllerTestCase extends AbstractControllerBa
self::assertEquals($title, $cell->text());
}
/**
* @dataProvider getTestData
*/
public function testUserPeriodReportExport(int $user, string $dataType, string $title): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
$this->importReportingFixture(User::ROLE_SUPER_ADMIN);
$this->assertAccessIsGranted($client, \sprintf('%s?user=%s&date=2023-12-23&sumType=%s', $this->getExportUrl(), $user, $dataType));
$response = $client->getResponse();
self::assertTrue($response->isSuccessful());
self::assertInstanceOf(BinaryFileResponse::class, $response);
// temporary file will be deleted!
$file = $response->getFile();
self::assertFileDoesNotExist($response->getFile());
$disposition = $response->headers->get('Content-Disposition');
self::assertIsString($disposition);
self::assertNotEmpty($disposition);
self::assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type'));
self::assertStringContainsString('attachment; filename=kimai-export-user-', $disposition);
}
public function testUserPeriodReportAsTeamlead(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);