Skip to content

Commit

Permalink
Try checking factory existence using file_exists instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperTey committed Nov 9, 2024
1 parent c5750bb commit 54df970
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Factories/DomainFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public static function resolveFactoryName(string $modelName)
}

// First try resolving as a factory class in the domain layer
if (class_exists($factoryClass = DomainResolver::getDomainObjectNamespace($model->domain, 'factory', "{$model->name}Factory"))) {
$factoryClass = DomainResolver::getDomainObjectNamespace($model->domain, 'factory', "{$model->name}Factory");
$factory = DomainObject::fromClass($factoryClass, 'factory');
if (file_exists(app()->basePath($factory->path))) {
return $factoryClass;
}

Expand Down
2 changes: 0 additions & 2 deletions tests/Factory/DomainFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
Config::set('ddd.base_model', 'Lunarstorm\LaravelDDD\Models\DomainModel');
Artisan::call("ddd:model -f {$domainParameter}:{$modelName}");

$this->composerReload();

expect(class_exists($modelClass))->toBeTrue();
expect($modelClass::factory())->toBeInstanceOf(Factory::class);
})->with([
Expand Down

0 comments on commit 54df970

Please sign in to comment.