Skip to content

Commit

Permalink
Try isolating test compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperTey committed Nov 10, 2024
1 parent e434f02 commit 8d1a418
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
34 changes: 22 additions & 12 deletions tests/Command/StubTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Illuminate\Support\Facades\File;
use Lunarstorm\LaravelDDD\Tests\Fixtures\Enums\Feature;

use function PHPUnit\Framework\assertDirectoryDoesNotExist;
use function PHPUnit\Framework\assertDirectoryExists;
Expand Down Expand Up @@ -105,17 +106,26 @@
->filter(fn ($stub, $path) => str($stub)->contains('model'))
->all();

$this
->artisan('ddd:stub')
->expectsQuestion('What do you want to do?', 'some')
->expectsSearch(
'Which stub should be published?',
search: 'model',
answers: $matches,
answer: ['model.stub']
)
->assertSuccessful()
->execute();
if (Feature::ExpectSearchAssertion->exists()) {
$this
->artisan('ddd:stub')
->expectsQuestion('What do you want to do?', 'some')
->expectsSearch(
'Which stub should be published?',
search: 'model',
answers: $matches,
answer: ['model.stub']
)
->assertSuccessful()
->execute();
} else {
$this
->artisan('ddd:stub')
->expectsQuestion('What do you want to do?', 'some')
->expectsQuestion('Which stub should be published?', ['model.stub'])
->assertSuccessful()
->execute();
}

assertDirectoryExists($publishedStubFolder);

Expand All @@ -124,4 +134,4 @@
expect(count($stubFiles))->toEqual(1);

expect($stubFiles[0]->getFilename())->toEqual('model.stub');
})->skipOnLaravelVersionsBelow('11.30.0');
});
2 changes: 1 addition & 1 deletion tests/Fixtures/Enums/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum Feature: string
case Laravel11 = '11.0.0';
case LaravelPromptsPackage = '10.17';
case LaravelPackageOptimizeCommands = '11.27.1';
case StubCommand = '11.30.0';
case ExpectSearchAssertion = '11.30.0';

public function exists(): bool
{
Expand Down

0 comments on commit 8d1a418

Please sign in to comment.