Skip to content

Commit f8061b3

Browse files
Merge pull request #102 from TheDragonCode/3.x
Fixed trying to execute files other than PHP
2 parents 4f312ee + ac1f702 commit f8061b3

File tree

5 files changed

+38
-13
lines changed

5 files changed

+38
-13
lines changed

src/Processors/Processor.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,33 @@ abstract class Processor
2424
{
2525
use Artisan;
2626

27-
abstract public function handle(): void;
28-
2927
public function __construct(
30-
protected Options $options,
31-
protected InputInterface $input,
32-
protected OutputStyle $output,
33-
protected Config $config,
28+
protected Options $options,
29+
protected InputInterface $input,
30+
protected OutputStyle $output,
31+
protected Config $config,
3432
protected ActionRepository $repository,
35-
protected Git $git,
36-
protected File $file,
37-
protected Migrator $migrator,
38-
protected Notification $notification,
39-
protected Dispatcher $events,
40-
protected Sorter $sorter
33+
protected Git $git,
34+
protected File $file,
35+
protected Migrator $migrator,
36+
protected Notification $notification,
37+
protected Dispatcher $events,
38+
protected Sorter $sorter
4139
) {
4240
$this->notification->setOutput($this->output, $this->options->silent);
4341
$this->repository->setConnection($this->options->connection);
4442
$this->migrator->setConnection($this->options->connection)->setOutput($this->output);
4543
}
4644

45+
abstract public function handle(): void;
46+
4747
protected function getFiles(string $path, ?Closure $filter = null): array
4848
{
4949
$file = Str::finish($path, '.php');
5050

5151
$files = $this->isFile($file) ? [$file] : $this->file->names($path, $filter, true);
5252

53-
$files = Arr::filter($files, fn (string $path) => ! Str::contains($path, $this->config->exclude()));
53+
$files = Arr::filter($files, fn (string $path) => Str::endsWith($path, '.php') && ! Str::contains($path, $this->config->exclude()));
5454

5555
return Arr::of($this->sorter->byValues($files))
5656
->map(fn (string $value) => Str::before($value, '.php'))

tests/Commands/MigrateTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,4 +652,21 @@ public function testFileExclusion()
652652
$this->assertDatabaseMigrationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz');
653653
$this->assertDatabaseMigrationHas($this->table, 'sub_path/2022_10_27_230732_foo');
654654
}
655+
656+
public function testEmptyDirectory()
657+
{
658+
$this->copyEmptyDirectory();
659+
660+
$table = 'every_time';
661+
662+
$this->artisan(Names::INSTALL)->assertExitCode(0);
663+
664+
$this->assertDatabaseCount($table, 0);
665+
$this->assertDatabaseCount($this->table, 0);
666+
$this->assertDatabaseMigrationDoesntLike($this->table, $table);
667+
$this->artisan(Names::MIGRATE)->assertExitCode(0);
668+
669+
$this->assertDatabaseCount($table, 0);
670+
$this->assertDatabaseCount($this->table, 0);
671+
}
655672
}

tests/Concerns/Files.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ protected function copyFiles(): void
2222
);
2323
}
2424

25+
protected function copyEmptyDirectory(): void
26+
{
27+
File::copyDirectory(
28+
__DIR__ . '/../fixtures/app/empty',
29+
$this->targetDirectory()
30+
);
31+
}
32+
2533
protected function copyDI(): void
2634
{
2735
File::copyDirectory(

tests/fixtures/app/empty/.gitkeep

Whitespace-only changes.

tests/fixtures/app/empty/some.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)