mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-16 14:39:37 +00:00
Fix fallback filename (#1238)
Some checks are pending
Build assets artifact / Build assets artifact (push) Waiting to run
Docker Image Build / docker (push) Waiting to run
Docker Image Build (FrankenPHP) / docker (push) Waiting to run
Static analysis / Static analysis (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Waiting to run
Some checks are pending
Build assets artifact / Build assets artifact (push) Waiting to run
Docker Image Build / docker (push) Waiting to run
Docker Image Build (FrankenPHP) / docker (push) Waiting to run
Static analysis / Static analysis (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Waiting to run
Fixes #1231. Modify tests to account for this case.
This commit is contained in:
parent
7998cdcd71
commit
97a74815d3
2 changed files with 11 additions and 8 deletions
|
|
@ -266,11 +266,14 @@ class EntityExporter
|
|||
//Sanitize the filename
|
||||
$filename = FilenameSanatizer::sanitizeFilename($filename);
|
||||
|
||||
//Remove percent for fallback
|
||||
$fallback = str_replace("%", "_", $filename);
|
||||
|
||||
// Create the disposition of the file
|
||||
$disposition = $response->headers->makeDisposition(
|
||||
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
|
||||
$filename,
|
||||
u($filename)->ascii()->toString(),
|
||||
$fallback,
|
||||
);
|
||||
// Set the content disposition
|
||||
$response->headers->set('Content-Disposition', $disposition);
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ final class EntityExporterTest extends WebTestCase
|
|||
|
||||
private function getEntities(): array
|
||||
{
|
||||
$entity1 = (new Category())->setName('Enitity 1')->setComment('Test');
|
||||
$entity1_1 = (new Category())->setName('Enitity 1.1')->setParent($entity1);
|
||||
$entity2 = (new Category())->setName('Enitity 2');
|
||||
$entity1 = (new Category())->setName('Entity%1')->setComment('Test');
|
||||
$entity1_1 = (new Category())->setName('Entity 1.1')->setParent($entity1);
|
||||
$entity2 = (new Category())->setName('Entity 2');
|
||||
|
||||
return [$entity1, $entity1_1, $entity2];
|
||||
}
|
||||
|
|
@ -55,12 +55,12 @@ final class EntityExporterTest extends WebTestCase
|
|||
$entities = $this->getEntities();
|
||||
|
||||
$json_without_children = $this->service->exportEntities($entities, ['format' => 'json', 'level' => 'simple']);
|
||||
$this->assertJsonStringEqualsJsonString('[{"name":"Enitity 1","type":"category","full_name":"Enitity 1"},{"name":"Enitity 1.1","type":"category","full_name":"Enitity 1->Enitity 1.1"},{"name":"Enitity 2","type":"category","full_name":"Enitity 2"}]',
|
||||
$this->assertJsonStringEqualsJsonString('[{"name":"Entity%1","type":"category","full_name":"Entity%1"},{"name":"Entity 1.1","type":"category","full_name":"Entity%1->Entity 1.1"},{"name":"Entity 2","type":"category","full_name":"Entity 2"}]',
|
||||
$json_without_children);
|
||||
|
||||
$json_with_children = $this->service->exportEntities($entities,
|
||||
['format' => 'json', 'level' => 'simple', 'include_children' => true]);
|
||||
$this->assertJsonStringEqualsJsonString('[{"children":[{"children":[],"name":"Enitity 1.1","type":"category","full_name":"Enitity 1->Enitity 1.1"}],"name":"Enitity 1","type":"category","full_name":"Enitity 1"},{"children":[],"name":"Enitity 1.1","type":"category","full_name":"Enitity 1->Enitity 1.1"},{"children":[],"name":"Enitity 2","type":"category","full_name":"Enitity 2"}]',
|
||||
$this->assertJsonStringEqualsJsonString('[{"children":[{"children":[],"name":"Entity 1.1","type":"category","full_name":"Entity%1->Entity 1.1"}],"name":"Entity%1","type":"category","full_name":"Entity%1"},{"children":[],"name":"Entity 1.1","type":"category","full_name":"Entity%1->Entity 1.1"},{"children":[],"name":"Entity 2","type":"category","full_name":"Entity 2"}]',
|
||||
$json_with_children);
|
||||
}
|
||||
|
||||
|
|
@ -95,8 +95,8 @@ final class EntityExporterTest extends WebTestCase
|
|||
$this->assertSame('name', $worksheet->getCell('A1')->getValue());
|
||||
$this->assertSame('full_name', $worksheet->getCell('B1')->getValue());
|
||||
|
||||
$this->assertSame('Enitity 1', $worksheet->getCell('A2')->getValue());
|
||||
$this->assertSame('Enitity 1', $worksheet->getCell('B2')->getValue());
|
||||
$this->assertSame('Entity%1', $worksheet->getCell('A2')->getValue());
|
||||
$this->assertSame('Entity%1', $worksheet->getCell('B2')->getValue());
|
||||
|
||||
unlink($tempFile);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue