Skip to content

Commit

Permalink
Wip;
Browse files Browse the repository at this point in the history
  • Loading branch information
hans-thomas committed Jan 20, 2025
1 parent be6e7cd commit 11fef3f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/Commands/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ public function handle(): int
if ($compactName === '' || filled($compactName) || $this->confirm('Should create a compact exception?')) {
$compactName = $compactName ?: $this->ask('What should be its name?');
if (blank($compactName)) {
if (version_compare(app()->version(), '11', '>=')) {
$this->fail('The name of the compact exception can not be empty.');
} elseif (version_compare(app()->version(), '10', '>=')) {
throw new \Exception('The name of the compact exception can not be empty.');
}
}
}
if ($compactName) {
Expand Down
4 changes: 0 additions & 4 deletions src/Commands/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ class_basename(MorphToRequest::class),
HasManyRequest::class,
])
) {
if (version_compare(app()->version(), '11', '>=')) {
$this->fail('The {related-name} parameter should not be empty when going to create a many-to-many relationship.');
} elseif (version_compare(app()->version(), '10', '>=')) {
throw new \Exception('The {related-name} parameter should not be empty when going to create a many-to-many relationship.');
}
}

if (in_array(
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Commands/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public function compactFormExceptionWithoutParamWithEmptyCompactName(): void
self::assertFileDoesNotExist($fullException);
self::assertFileDoesNotExist($compactException);

$this->expectExceptionMessage('The name of the compact exception can not be empty.');

$this->artisan('valravn:exception blog posts BPEcx')
->expectsConfirmation('Should create a compact exception?', 'yes')
->expectsQuestion('What should be its name?', '')
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Commands/RelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ public function belongsToManyWithoutRelatedName(): void

self::assertFileDoesNotExist($file);

$this->expectExceptionMessage('The {related-name} parameter should not be empty when going to create a many-to-many relationship.');

$this->artisan('valravn:relation blog Post core --belongs-to-many')
->assertFailed();

Expand Down

0 comments on commit 11fef3f

Please sign in to comment.