Skip to content

Commit

Permalink
User autoload ->run instead of ->boot
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspertey committed Nov 17, 2024
1 parent fb79601 commit 57774a4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions tests/Autoload/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

$mock = AutoloadManager::partialMock();
$mock->shouldNotReceive('handleCommands');
$mock->boot();
$mock->run();

expect($mock->getRegisteredCommands())->toBeEmpty();
});
Expand All @@ -42,7 +42,7 @@
config()->set('ddd.autoload.commands', true);

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

expect(array_values($mock->getRegisteredCommands()))->toEqualCanonicalizing(array_values($this->commands));
});
Expand All @@ -55,7 +55,7 @@
config()->set('ddd.autoload.commands', true);

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

expect(array_values($mock->getRegisteredCommands()))->toEqualCanonicalizing([]);
});
Expand All @@ -65,7 +65,7 @@
DomainCache::clear();

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

expect(array_values($mock->getRegisteredCommands()))->toEqualCanonicalizing(array_values($this->commands));
});
Expand Down
8 changes: 4 additions & 4 deletions tests/Autoload/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

$mock = AutoloadManager::partialMock();
$mock->shouldReceive('handleFactories')->once();
$mock->boot();
$mock->run();
});

it('can resolve domain factory', function ($modelClass, $expectedFactoryClass) {
config()->set('ddd.autoload.factories', true);

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

expect($modelClass::factory())->toBeInstanceOf($expectedFactoryClass);
})->with([
Expand Down Expand Up @@ -71,14 +71,14 @@

$mock = AutoloadManager::partialMock();
$mock->shouldNotReceive('handleFactories');
$mock->boot();
$mock->run();
});

it('cannot resolve factories that rely on autoloading', function ($modelClass, $correctFactories) {
config()->set('ddd.autoload.factories', false);

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

expect(fn () => $modelClass::factory())->toThrow(Error::class);
})->with([
Expand Down
8 changes: 4 additions & 4 deletions tests/Autoload/PolicyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

$mock = AutoloadManager::partialMock();
$mock->shouldNotReceive('handlePolicies');
$mock->boot();
$mock->run();
});
});

Expand All @@ -42,14 +42,14 @@

$mock = AutoloadManager::partialMock();
$mock->shouldReceive('handlePolicies')->once();
$mock->boot();
$mock->run();
});

it('can resolve the policies', function () {
config()->set('ddd.autoload.policies', true);

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

foreach ($this->policies as $class => $expectedPolicy) {
$resolvedPolicy = Gate::getPolicyFor($class);
Expand All @@ -61,7 +61,7 @@
config()->set('ddd.autoload.policies', true);

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

expect(class_exists($class))->toBeTrue();
expect(Gate::getPolicyFor($class))->toBeInstanceOf($expectedPolicy);
Expand Down
12 changes: 6 additions & 6 deletions tests/Autoload/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@

$mock = AutoloadManager::partialMock();
$mock->shouldNotReceive('handleProviders');
$mock->boot();
$mock->run();
});

it('does not register the providers', function () {
config()->set('ddd.autoload.providers', false);

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

expect($mock->getRegisteredProviders())->toBeEmpty();
});
Expand All @@ -50,14 +50,14 @@

$mock = AutoloadManager::partialMock();
$mock->shouldReceive('handleProviders')->once();
$mock->boot();
$mock->run();
});

it('registers the providers', function () {
config()->set('ddd.autoload.providers', true);

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

expect(array_values($mock->getRegisteredProviders()))->toEqualCanonicalizing($this->providers);
});
Expand All @@ -70,7 +70,7 @@
config()->set('ddd.autoload.providers', true);

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

expect(array_values($mock->getRegisteredProviders()))->toEqualCanonicalizing([]);
});
Expand All @@ -82,7 +82,7 @@
config()->set('ddd.autoload.providers', true);

$mock = AutoloadManager::partialMock();
$mock->boot();
$mock->run();

expect(array_values($mock->getRegisteredProviders()))->toEqualCanonicalizing($this->providers);
});
Expand Down

0 comments on commit 57774a4

Please sign in to comment.