-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support of Momentum Trail from @lepikhinb
- Loading branch information
1 parent
912205b
commit fc3a32c
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Qruto\Flora\Discovers; | ||
|
||
use Illuminate\Container\Container; | ||
use Illuminate\Support\Facades\Artisan; | ||
use Illuminate\Support\Facades\Blade; | ||
use Qruto\Flora\Run; | ||
use function class_exists; | ||
use function config; | ||
|
||
class TrailDiscover implements PackageDiscover | ||
{ | ||
public function exists(): bool | ||
{ | ||
return collect(Artisan::all())->has('trail:generate'); | ||
} | ||
|
||
public function instruction(): Instruction | ||
{ | ||
$command = fn (Run $run): Run => $run->command('trail:generate'); | ||
|
||
return new Instruction( | ||
install: $command, | ||
update: $command, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Artisan; | ||
use Qruto\Flora\Actions\Artisan as ArtisanAction; | ||
use Qruto\Flora\Console\Commands\PackageInstruction; | ||
use Qruto\Flora\Enums\Environment; | ||
use Qruto\Flora\Enums\FloraType; | ||
|
||
uses(PackageInstruction::class); | ||
|
||
beforeEach(function () { | ||
Artisan::command('trail:generate', fn() => null); | ||
}); | ||
|
||
it('successfully instruct trail:generate for local environment', function () { | ||
$run = makeRunner(); | ||
|
||
$this->instructPackages(FloraType::Install, Environment::Local->value, $run); | ||
|
||
$this->assertCount(1, $run->internal->getCollection()); | ||
$this->assertContainsOnlyInstancesOf(ArtisanAction::class, $run->internal->getCollection()); | ||
$this->assertEquals( | ||
[ | ||
'trail:generate', | ||
], | ||
collect($run->internal->getCollection()) | ||
->map(fn ($action) => $action->name()) | ||
->toArray() | ||
); | ||
}); | ||
|
||
it('successfully instruct trail:generate for production environment', function () { | ||
$run = makeRunner(); | ||
|
||
$this->instructPackages(FloraType::Install, Environment::Production->value, $run); | ||
|
||
$this->assertCount(1, $run->internal->getCollection()); | ||
$this->assertContainsOnlyInstancesOf(ArtisanAction::class, $run->internal->getCollection()); | ||
$this->assertEquals( | ||
[ | ||
'trail:generate', | ||
], | ||
collect($run->internal->getCollection()) | ||
->map(fn ($action) => $action->name()) | ||
->toArray() | ||
); | ||
}); |