Skip to content

Commit

Permalink
Attempt resetting artisan on test environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspertey committed Nov 16, 2024
1 parent ee5daaf commit 5b58587
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Support/AutoloadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ protected function run()
}

if (app()->runningInConsole() && ! $this->isConsoleBooted()) {
ConsoleApplication::starting(function ($artisan) {
ConsoleApplication::starting(function (ConsoleApplication $artisan) {
foreach ($this->registeredCommands as $command) {
$artisan->resolve($command);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/Autoload/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
];

$this->setupTestApplication();
DomainCache::clear();
});

afterEach(function () {
Expand All @@ -35,10 +34,12 @@

$mock->boot();

expect($mock->getRegisteredCommands())->toBeEmpty();

$artisanCommands = collect(Artisan::all());

expect($artisanCommands)->not->toHaveKeys(array_keys($this->commands));
});
})->only();

it('does not register the commands', function () {
config()->set('ddd.autoload.commands', false);
Expand Down
1 change: 0 additions & 1 deletion tests/Autoload/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

beforeEach(function () {
$this->setupTestApplication();
DomainCache::clear();
});

afterEach(function () {
Expand Down
1 change: 0 additions & 1 deletion tests/Autoload/IgnoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
];

$this->setupTestApplication();
DomainCache::clear();
});

afterEach(function () {
Expand Down
1 change: 0 additions & 1 deletion tests/Autoload/PolicyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
];

$this->setupTestApplication();
DomainCache::clear();
});

afterEach(function () {
Expand Down
1 change: 0 additions & 1 deletion tests/Autoload/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
];

$this->setupTestApplication();
DomainCache::clear();
});

afterEach(function () {
Expand Down
10 changes: 10 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lunarstorm\LaravelDDD\Tests;

use Illuminate\Console\Application as ConsoleApplication;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Arr;
Expand Down Expand Up @@ -228,6 +229,15 @@ protected function setupTestApplication()
$this->setAutoloadPathInComposer('Application', 'src/Application');
$this->setAutoloadPathInComposer('Infrastructure', 'src/Infrastructure');

$this->resetArtisan();

return $this;
}

protected function resetArtisan()
{
ConsoleApplication::forgetBootstrappers();

return $this;
}

Expand Down

0 comments on commit 5b58587

Please sign in to comment.