Add Arch tests
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2024-09-22 22:58:31 +02:00
parent 1521aba1f8
commit f858716e57
3 changed files with 29 additions and 0 deletions

View File

@ -10,6 +10,9 @@
<testsuite name="Fileshare"> <testsuite name="Fileshare">
<directory suffix="Test.php">./tests/Fileshare</directory> <directory suffix="Test.php">./tests/Fileshare</directory>
</testsuite> </testsuite>
<testsuite name="Arch">
<file>tests/Arch.php</file>
</testsuite>
<testsuite name="NamiUnit"> <testsuite name="NamiUnit">
<directory suffix="Test.php">./packages/laravel-nami/tests/Unit</directory> <directory suffix="Test.php">./packages/laravel-nami/tests/Unit</directory>
</testsuite> </testsuite>

15
tests/Arch.php Normal file
View File

@ -0,0 +1,15 @@
<?php
arch()
->expect('App')
->not->toUse(['die', 'dd', 'dump']);
arch()
->expect(globArch('App\*\Models'))
->toExtend('Illuminate\Database\Eloquent\Model')
->toBeClasses();
arch('app')
->expect('App')
->not->toHaveFileSystemPermissions('0777');

View File

@ -11,6 +11,8 @@
| |
*/ */
use Symfony\Component\Finder\Finder;
uses( uses(
Tests\TestCase::class, Tests\TestCase::class,
// Illuminate\Foundation\Testing\RefreshDatabase::class, // Illuminate\Foundation\Testing\RefreshDatabase::class,
@ -41,3 +43,12 @@ uses(
| global functions to help you to reduce the number of lines of code in your test files. | global functions to help you to reduce the number of lines of code in your test files.
| |
*/ */
function globArch(string $pattern)
{
$files = iterator_to_array(Finder::create()->files()->in(str($pattern)->replaceStart('App', './app')->replace('\\', '/'))->name('*.php'));
return collect($files)->map(
fn ($file) => str($file->getPathname())->replaceStart('./app', 'App')->replace('/', '\\')->replaceEnd('.php', '')->toString()
)->values()->toArray();
}