Skip to content

Commit

Permalink
Isolate laravel11 specific stub tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperTey committed Nov 10, 2024
1 parent 55be808 commit 303e4b6
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions tests/Command/StubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,38 @@
}
})->with([
'model*' => ['model*', ['model', 'model.pivot']],
'model.' => ['model*', ['model', 'model.pivot']],
'model.' => ['model.', ['model', 'model.pivot']],
'listener*' => ['listener*', ['listener', 'listener.typed', 'listener.queued', 'listener.typed.queued']],
'listener.' => ['listener*', ['listener', 'listener.typed', 'listener.queued', 'listener.typed.queued']],
'listener.' => ['listener.', ['listener', 'listener.typed', 'listener.queued', 'listener.typed.queued']],
]);

it('can publish stubs using wildcard (laravel 11 stubs)', function ($argument, $stubsToPublish) {
$expectedStubFilenames = collect($stubsToPublish)
->map(fn ($stub) => $stub.'.stub')
->all();

$this
->artisan("ddd:stub {$argument}")
->assertSuccessful()
->execute();

$publishedStubFolder = app()->basePath('stubs/ddd');

assertDirectoryExists($publishedStubFolder);

$stubFiles = File::files($publishedStubFolder);

expect(count($stubFiles))->toEqual(count($stubsToPublish));

foreach ($stubFiles as $file) {
expect($file->getFilename())->toBeIn($expectedStubFilenames);
}
})->with([
'listener*' => ['listener*', ['listener', 'listener.typed', 'listener.queued', 'listener.typed.queued']],
'listener.' => ['listener.', ['listener', 'listener.typed', 'listener.queued', 'listener.typed.queued']],
'enum.' => ['enum.', ['enum', 'enum.backed']],
])->skipOnLaravelVersionsBelow(11);

it('can publish specific stubs interactively', function () {
$publishedStubFolder = app()->basePath('stubs/ddd');

Expand Down

0 comments on commit 303e4b6

Please sign in to comment.