Skip to content

Commit

Permalink
style(tests): refactor cleanup logic in Pest.php
Browse files Browse the repository at this point in the history
- Replace inline cleanup logic with a dedicated function `clear_name_namespace()`.
- Improve readability and maintainability of the test setup.
- Update `composer.json` to require `illuminate/validation` version `^11.23`.
  • Loading branch information
guanguans committed Sep 14, 2024
1 parent cebae9a commit 7b73d1c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 52 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"php": "^8.3",
"cerbero/command-validator": "^3.0",
"graham-campbell/github": "^12.6",
"illuminate/validation": "^11.22",
"illuminate/validation": "^11.23",
"laminas/laminas-feed": "^2.22",
"laravel-zero/framework": "^11.0"
},
Expand Down
83 changes: 42 additions & 41 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,7 @@

uses(Tests\TestCase::class)
->beforeAll(function (): void {
foreach (
Symfony\Component\Finder\Finder::create()
->in(__DIR__.'/../vendor/guanguans/ai-commit/app')
->notName('helpers.php')
->name('*.php') as $splFileInfo
) {
unlink($splFileInfo->getPathname());
}

file_put_contents(__DIR__.'/../vendor/guanguans/ai-commit/app/Support/helpers.php', '<?php');
clear_name_namespace();
})
->beforeEach(function (): void {})
->afterEach(function (): void {})
Expand Down Expand Up @@ -87,3 +78,17 @@ function fixtures_path(string $path = ''): string
{
return __DIR__.'/Fixtures'.($path ? \DIRECTORY_SEPARATOR.$path : $path);
}

function clear_name_namespace(): void
{
foreach (
Symfony\Component\Finder\Finder::create()
->in(__DIR__.'/../vendor/guanguans/ai-commit/app')
->notName('helpers.php')
->name('*.php') as $splFileInfo
) {
unlink($splFileInfo->getPathname());
}

file_put_contents(__DIR__.'/../vendor/guanguans/ai-commit/app/Support/helpers.php', '<?php');
}

0 comments on commit 7b73d1c

Please sign in to comment.