-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add FileSystem helper; cleanup
- Loading branch information
Showing
7 changed files
with
39 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buggregator\Trap\Support; | ||
|
||
/** | ||
* @internal | ||
* @psalm-internal Buggregator\Trap | ||
*/ | ||
final class FileSystem | ||
{ | ||
public static function mkdir(string $path, int $mode = 0777, bool $recursive = true): void | ||
{ | ||
\is_dir($path) or \mkdir($path, $mode, $recursive) or \is_dir($path) or throw new \RuntimeException( | ||
\sprintf('Directory "%s" was not created.', $path), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,14 +16,6 @@ final class MailToFileSenderTest extends TestCase | |
{ | ||
private array $cleanupFolders = []; | ||
|
||
protected function tearDown(): void | ||
{ | ||
foreach ($this->cleanupFolders as $folder) { | ||
\array_map('unlink', glob("$folder/*.*")); | ||
\rmdir($folder); | ||
} | ||
} | ||
|
||
public function testForSmtp(): void | ||
{ | ||
$this->cleanupFolders[] = $root = \sys_get_temp_dir() . DIRECTORY_SEPARATOR . \uniqid('trap_mail_'); | ||
|
@@ -48,11 +40,19 @@ public function testForSmtp(): void | |
$this->assertRecipient("$root/[email protected]"); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
foreach ($this->cleanupFolders as $folder) { | ||
\array_map('unlink', \glob("$folder/*.*")); | ||
\rmdir($folder); | ||
} | ||
} | ||
|
||
private function assertRecipient(string $folder): void | ||
{ | ||
self::assertTrue(\file_exists($folder)); | ||
self::assertTrue(\is_dir($folder)); | ||
$files = glob("$folder/*.json"); | ||
$files = \glob("$folder/*.json"); | ||
self::assertCount(1, $files); | ||
$arr = \json_decode(\file_get_contents($files[0]), true, \JSON_THROW_ON_ERROR); | ||
self::assertArrayHasKey('protocol', $arr); | ||
|