Skip to content

Commit f376f69

Browse files
committed
feat(tests): create initial PHPUnit test files for all exception classes
- Added PHPUnit test classes for each exception class under `tests` directory - Created directory structure mirroring the source code for proper organization of tests
1 parent f4a883a commit f376f69

30 files changed

+120
-32
lines changed

createDirectory.php

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,48 @@ function createDirectory(string $path): void
1212
function createFile(string $filePath): void
1313
{
1414
$content = "<?php\n\ndeclare(strict_types=1);\n";
15+
1516
if (!file_exists($filePath)) {
1617
file_put_contents($filePath, $content);
1718
}
1819
}
1920

20-
$baseDir = __DIR__ . '/src';
21+
$baseDir = __DIR__ . '/tests';
2122

2223
// Directories and their respective files
2324
$structure = [
24-
'AbstractException.php',
25-
'AbstractErrorMessage.php',
26-
'Contract/ErrorMessage.php',
27-
'Contract/Throwable.php',
28-
'CommonErrorMessages.php',
29-
'Auth/AuthenticationException.php',
30-
'Auth/AuthorizationException.php',
31-
'Validation/ValidationException.php',
32-
'Validation/RuleViolationException.php',
33-
'File/FileException.php',
34-
'Input/InputException.php',
35-
'Runtime/RuntimeException.php',
36-
'System/SystemException.php',
37-
'Security/SecurityException.php',
38-
'Security/EncryptionException.php',
39-
'Config/ConfigurationException.php',
40-
'Network/NetworkException.php',
41-
'Network/HttpException.php',
42-
'Database/DatabaseException.php',
43-
'Cache/CacheException.php',
44-
'ExternalService/ExternalServiceException.php',
45-
'Localization/LocalizationException.php',
46-
'Event/EventException.php',
47-
'Middleware/MiddlewareException.php',
48-
'Queue/QueueException.php',
49-
'Routing/RoutingException.php',
50-
'Template/TemplateException.php',
51-
'Session/SessionException.php',
52-
'Container/ContainerException.php',
25+
'AbstractExceptionTest.php',
26+
'AbstractErrorMessageTest.php',
27+
'Contract/ErrorMessageTest.php',
28+
'Contract/ThrowableTest.php',
29+
'CommonErrorMessagesTest.php',
30+
'Auth/AuthenticationExceptionTest.php',
31+
'Auth/AuthorizationExceptionTest.php',
32+
'Validation/ValidationExceptionTest.php',
33+
'Validation/RuleViolationExceptionTest.php',
34+
'File/FileExceptionTest.php',
35+
'Input/InputExceptionTest.php',
36+
'Runtime/RuntimeExceptionTest.php',
37+
'System/SystemExceptionTest.php',
38+
'Security/SecurityExceptionTest.php',
39+
'Security/EncryptionExceptionTest.php',
40+
'Config/ConfigurationExceptionTest.php',
41+
'Network/NetworkExceptionTest.php',
42+
'Network/HttpExceptionTest.php',
43+
'Database/DatabaseExceptionTest.php',
44+
'Cache/CacheExceptionTest.php',
45+
'ExternalService/ExternalServiceExceptionTest.php',
46+
'Localization/LocalizationExceptionTest.php',
47+
'Event/EventExceptionTest.php',
48+
'Middleware/MiddlewareExceptionTest.php',
49+
'Queue/QueueExceptionTest.php',
50+
'Routing/RoutingExceptionTest.php',
51+
'Template/TemplateExceptionTest.php',
52+
'Session/SessionExceptionTest.php',
53+
'Container/ContainerExceptionTest.php',
5354
];
5455

55-
// Create directories and files
56+
// Create directories and files for tests
5657
foreach ($structure as $filePath) {
5758
$fullPath = $baseDir . '/' . $filePath;
5859
$directory = dirname($fullPath);
@@ -64,4 +65,4 @@ function createFile(string $filePath): void
6465
createFile($fullPath);
6566
}
6667

67-
echo "Directories and files created successfully!\n";
68+
echo "Test directories and files created successfully!\n";

tests/AbstractErrorMessageTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
declare(strict_types=1);

tests/AbstractExceptionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
declare(strict_types=1);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
declare(strict_types=1);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
declare(strict_types=1);

tests/Cache/CacheExceptionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
declare(strict_types=1);

tests/CommonErrorMessagesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
declare(strict_types=1);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
declare(strict_types=1);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
declare(strict_types=1);

tests/Contract/ErrorMessageTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
declare(strict_types=1);

0 commit comments

Comments
 (0)