From 377bff77fc69b621678c9f3eb2ea2328624786d8 Mon Sep 17 00:00:00 2001 From: Jasper Tey Date: Sat, 9 Nov 2024 14:11:08 -0500 Subject: [PATCH] Attempt booting with autoload enabled. --- src/Factories/DomainFactory.php | 3 +-- tests/Factory/DomainFactoryTest.php | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Factories/DomainFactory.php b/src/Factories/DomainFactory.php index b567860..5c0b7b8 100644 --- a/src/Factories/DomainFactory.php +++ b/src/Factories/DomainFactory.php @@ -37,8 +37,7 @@ public static function resolveFactoryName(string $modelName) // First try resolving as a factory class in the domain layer $factoryClass = DomainResolver::getDomainObjectNamespace($model->domain, 'factory', "{$model->name}Factory"); - $factory = DomainObject::fromClass($factoryClass, 'factory'); - if (file_exists(app()->basePath($factory->path))) { + if (class_exists($factoryClass)) { return $factoryClass; } diff --git a/tests/Factory/DomainFactoryTest.php b/tests/Factory/DomainFactoryTest.php index d7e8275..82e6e54 100644 --- a/tests/Factory/DomainFactoryTest.php +++ b/tests/Factory/DomainFactoryTest.php @@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Config; use Lunarstorm\LaravelDDD\Factories\DomainFactory; +use Lunarstorm\LaravelDDD\Support\DomainAutoloader; it('can resolve the factory name of a domain model', function ($modelClass, $expectedFactoryClass) { $this->setupTestApplication(); @@ -27,6 +28,10 @@ ]); it('can instantiate a domain model factory', function ($domainParameter, $modelName, $modelClass) { + $this->afterApplicationCreated(function () { + (new DomainAutoloader)->autoload(); + }); + $this->setupTestApplication(); Config::set('ddd.base_model', 'Lunarstorm\LaravelDDD\Models\DomainModel');