Skip to content

Commit a85e956

Browse files
committed
fix: remarks from reviewer
1 parent 318cd18 commit a85e956

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/Generators/EntityGenerator.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use RonasIT\Support\DTO\RelationsDTO;
1313
use RonasIT\Support\Events\WarningEvent;
1414
use Illuminate\Database\Eloquent\Relations\BelongsTo;
15-
use RonasIT\Support\Exceptions\ClassNotExistsException;
1615
use RonasIT\Support\Exceptions\ResourceNotExistsException;
1716
use RonasIT\Support\Exceptions\IncorrectClassPathException;
1817
use RonasIT\Support\Exceptions\ResourceAlreadyExistsException;
@@ -215,11 +214,7 @@ protected function getRelatedModels(string $model, string $creatableClass): arra
215214
$modelClass = $this->getModelClass($model);
216215

217216
if (!class_exists($modelClass)) {
218-
$this->throwFailureException(
219-
exceptionClass: ClassNotExistsException::class,
220-
failureMessage: "Cannot create {$creatableClass} cause {$model} Model does not exists.",
221-
recommendedMessage: "Create a {$model} Model by himself or run command 'php artisan make:entity {$model} --only-model'.",
222-
);
217+
throw new ResourceNotExistsException($creatableClass, $model);
223218
}
224219

225220
$instance = new $modelClass();

tests/TestGeneratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use RonasIT\Support\Events\SuccessCreateMessage;
99
use RonasIT\Support\Tests\Support\Test\TestMockTrait;
1010
use RonasIT\Support\Exceptions\ClassNotExistsException;
11+
use RonasIT\Support\Exceptions\ResourceNotExistsException;
1112
use RonasIT\Support\Exceptions\ResourceAlreadyExistsException;
1213
use RonasIT\Support\Exceptions\CircularRelationsFoundedException;
1314

@@ -30,9 +31,8 @@ public function setUp(): void
3031
public function testMissingModel()
3132
{
3233
$this->assertExceptionThrew(
33-
className: ClassNotExistsException::class,
34-
message: "Cannot create PostTest cause Post Model does not exists. "
35-
. "Create a Post Model by himself or run command 'php artisan make:entity Post --only-model'.",
34+
className: ResourceNotExistsException::class,
35+
message: 'Cannot create PostTest cause Post does not exist. Create Post and run command again.',
3636
);
3737

3838
app(TestsGenerator::class)

0 commit comments

Comments
 (0)