Skip to content

Commit

Permalink
dev: Fix some PHPUnit Testdox warnings
Browse files Browse the repository at this point in the history
I detected these warnings by running the tests of this specific file.
It appears that silenced warnings are detected by the Testdox output,
but not by the default output. The best would be to never use `@`
anyway.

Reference: sebastianbergmann/phpunit#5884
  • Loading branch information
marien-probesys committed Aug 14, 2024
1 parent 57118af commit 59c8441
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions tests/Service/DataImporter/DataImporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1334,8 +1334,7 @@ public function testImportTicketsImportsDocumentsAsWell(): void
],
],
];
$documentsPath = sys_get_temp_dir() . '/documents';
@mkdir($documentsPath);
$documentsPath = $this->createDocumentsFolder();
$content = 'My bug';
$hash = hash('sha256', $content);
file_put_contents($documentsPath . '/bug.txt', $content);
Expand Down Expand Up @@ -2058,9 +2057,11 @@ public function testImportTicketsFailsIfDocumentIsMissing(): void
],
],
];
$documentsPath = sys_get_temp_dir() . '/documents';
@mkdir($documentsPath);
@unlink($documentsPath . '/bug.txt');
$documentsPath = $this->createDocumentsFolder();
$filepath = "{$documentsPath}/bug.txt";
if (file_exists($filepath)) {
unlink($filepath);
}

$this->processGenerator($this->dataImporter->import(
organizations: $organizations,
Expand All @@ -2072,4 +2073,15 @@ public function testImportTicketsFailsIfDocumentIsMissing(): void
$this->assertSame(0, MessageFactory::count());
$this->assertSame(0, MessageDocumentFactory::count());
}

private function createDocumentsFolder(): string
{
$documentsPath = sys_get_temp_dir() . '/documents';

if (!is_dir($documentsPath)) {
mkdir($documentsPath);
}

return $documentsPath;
}
}

0 comments on commit 59c8441

Please sign in to comment.