Skip to content

Commit

Permalink
feat: add tests (#11)
Browse files Browse the repository at this point in the history
* feat: add tests

* fix: naming of tests

* Fix styling

---------

Co-authored-by: emilhorlyck <[email protected]>
  • Loading branch information
emilhorlyck and emilhorlyck authored Oct 16, 2023
1 parent 3095cf9 commit cde4823
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Commands/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function handle(): int
// - [ ] Conventional commit script
// - [ ] Release script
// - [ ] Pre push git hook for pest
// - [ ] Run tests
// - [ ] Add tests
// - [x] Fillament Admin panel

$initSteps = [
Expand All @@ -43,7 +43,7 @@ public function handle(): int
// 'conventional-commits' => 'Conventional commit script',
// 'release' => 'Release script',
// 'pre-push' => 'Pre push git hook for pest',
// 'tests' => 'Run tests',
'tests' => 'Add tests',
'admin' => 'Fillament Admin panel',
];

Expand Down Expand Up @@ -316,10 +316,13 @@ public function handle(): int
info('Fillament installed successfully. go to /admin to see the admin panel.');
}

// Run tests
// Add tests
if ($chosenSteps->contains('tests')) {
$this->info('Adding tests...');
exec('php artisan vendor:publish --tag=Laravel-pareto-tests');
$this->info('Tests added successfully.');
exec('./vendor/bin/pest --init');
exec('./vendor/bin/pest');
// exec('./vendor/bin/pest');
}

return self::SUCCESS;
Expand Down
4 changes: 4 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ public function boot(): void
InitCommand::class,
]);
}

$this->publishes([
__DIR__.'/../tests/ArchTest.php' => config_path('../tests/Feature/Pareto/ArchTest.php'),
], 'Laravel-pareto-tests');
}
}
38 changes: 38 additions & 0 deletions tests/ArchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,41 @@
it('will not use debugging functions')
->expect(['dd', 'dump', 'ray'])
->not->toBeUsed();

test('invokable actions')
->expect('App\Actions')
->toBeInvokable();

test('models extend eloquent')
->expect('App\Models')
->toExtend('Illuminate\Database\Eloquent\Model');

test('jobs implement should queue')
->expect('App\Jobs')
->toImplement('Illuminate\Contracts\Queue\ShouldQueue');

// Suffixes

test('controllers end with controller')
->expect('App\Http\Controllers')
->toHaveSuffix('Controller');

test('jobs end with job')
->expect('App\Jobs')
->toHaveSuffix('Job');

test('clients end with client')
->expect('App\Http\Clients')
->toHaveSuffix('Client');

test('factories end with factory')
->expect('App\databases\factories')
->toHaveSuffix('Factory');

test('seeders end with seeder')
->expect('App\database\seeders')
->toHaveSuffix('Seeder');

test('providers end with provider')
->expect('App\Providers')
->toHaveSuffix('Provider');

0 comments on commit cde4823

Please sign in to comment.