Skip to content

Commit

Permalink
Reset test state
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed May 19, 2023
1 parent 5d61109 commit 99c7d79
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Support/DatabaseFactoryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public function __construct(ModuleRegistry $registry)
$this->registry = $registry;
}

public function resetResolvers()
{
$this->unsetProperty(Factory::class, 'modelNameResolver');
$this->unsetProperty(Factory::class, 'factoryNameResolver');
}

public function modelNameResolver(): Closure
{
return function(Factory $factory) {
Expand Down
2 changes: 2 additions & 0 deletions tests/ModularServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public function test_model_factory_classes_are_resolved_correctly_with_custom_na
'Something\\Foo\\BarFactory',
Factory::resolveFactoryName('App\\Foo\\Bar')
);

Factory::useNamespace('Database\\Factories\\');
}

public function test_model_classes_are_resolved_correctly_for_factories_with_custom_namespace(): void
Expand Down
8 changes: 8 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Encryption\Encrypter;
use InterNACHI\Modular\Console\Commands\Make\MakeModule;
use InterNACHI\Modular\Support\DatabaseFactoryHelper;
use InterNACHI\Modular\Support\Facades\Modules;
use InterNACHI\Modular\Support\ModularizedCommandsServiceProvider;
use InterNACHI\Modular\Support\ModularServiceProvider;
Expand All @@ -27,6 +28,13 @@ protected function setUp(): void
// $this->app['view']->addLocation(__DIR__.'/Feature/stubs');
}

protected function tearDown(): void
{
$this->app->make(DatabaseFactoryHelper::class)->resetResolvers();

parent::tearDown();
}

protected function makeModule(string $name = 'test-module'): ModuleConfig
{
$this->artisan(MakeModule::class, [
Expand Down

0 comments on commit 99c7d79

Please sign in to comment.