Skip to content

Commit

Permalink
Tests fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
LastDragon-ru committed May 27, 2024
1 parent 4ff99e8 commit f56a32d
Showing 1 changed file with 40 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeArtisan;

use Composer\InstalledVersions;
use Composer\Semver\VersionParser;
use Illuminate\Contracts\Console\Kernel;
use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
Expand Down Expand Up @@ -33,21 +35,25 @@ public function testInvoke(): void {
$instance = $this->app()->make(Instruction::class);

$this->override(Kernel::class, static function (MockInterface $mock) use ($command, $expected): void {
$mock
->shouldReceive('addCommands')
->atLeast()
->once()
->andReturns();
$mock
->shouldReceive('addCommandPaths')
->atLeast()
->once()
->andReturns();
$mock
->shouldReceive('addCommandRoutePaths')
->atLeast()
->once()
->andReturns();
if (InstalledVersions::satisfies(new VersionParser(), 'illuminate/contracts', '^11.0.0')) {
// todo(documentator): Remove after https://github.com/LastDragon-ru/lara-asp/issues/143
$mock
->shouldReceive('addCommands')
->atLeast()
->once()
->andReturns();
$mock
->shouldReceive('addCommandPaths')
->atLeast()
->once()
->andReturns();
$mock
->shouldReceive('addCommandRoutePaths')
->atLeast()
->once()
->andReturns();
}

$mock
->shouldReceive('handle')
->withArgs(
Expand Down Expand Up @@ -77,21 +83,25 @@ public function testInvokeFailed(): void {
$instance = $this->app()->make(Instruction::class);

$this->override(Kernel::class, static function (MockInterface $mock) use ($command): void {
$mock
->shouldReceive('addCommands')
->atLeast()
->once()
->andReturns();
$mock
->shouldReceive('addCommandPaths')
->atLeast()
->once()
->andReturns();
$mock
->shouldReceive('addCommandRoutePaths')
->atLeast()
->once()
->andReturns();
// todo(documentator): Remove after https://github.com/LastDragon-ru/lara-asp/issues/143
if (InstalledVersions::satisfies(new VersionParser(), 'illuminate/contracts', '^11.0.0')) {
$mock
->shouldReceive('addCommands')
->atLeast()
->once()
->andReturns();
$mock
->shouldReceive('addCommandPaths')
->atLeast()
->once()
->andReturns();
$mock
->shouldReceive('addCommandRoutePaths')
->atLeast()
->once()
->andReturns();
}

$mock
->shouldReceive('handle')
->withArgs(
Expand Down

0 comments on commit f56a32d

Please sign in to comment.