Skip to content

Commit

Permalink
Ignore abstract classes model (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethsandaru authored Oct 29, 2023
1 parent c70834d commit 292d4db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Commands/BulkEloquentDocsGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,15 @@ private function getModels(): Collection
->map(function (string $file) {
$className = $this->getFullyQualifiedClassName($file);

$initializedModel = rescue(
fn () => app()->make($className),
fn () => null
);

return [
'modelClass' => $className,
'modelFilePath' => $file,
'modelInstance' => app($className),
'modelInstance' => $initializedModel,
];
})
->filter(fn ($model) => $model['modelInstance'] instanceof Model)
Expand Down
1 change: 1 addition & 0 deletions tests/Features/BulkEloquentDocsGeneratorCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function testCommandReturnsOkGeneratedDocsForAllModelFilesInPath()
$this->artisan('eloquent:bulk-phpdoc "tests/Fixtures/BulkFixtures/*.php"')
->expectsOutputToContain('Generated & Saved for:')
->expectsOutputToContain('Generated EloquentDocs for 3 model file(s)')
->doesntExpectOutputToContain('BaseModel')
->assertSuccessful();

// the generation & storing actually tested in EloquentDocsGeneratorCommandTest, no need to re-assert the same here.
Expand Down
10 changes: 10 additions & 0 deletions tests/Fixtures/BulkFixtures/BaseModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace SethPhat\EloquentDocs\Tests\Fixtures\BulkFixtures;

use Illuminate\Database\Eloquent\Model;

abstract class BaseModel extends Model
{

}

0 comments on commit 292d4db

Please sign in to comment.