Skip to content

Fixed trying to execute files other than PHP #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Processors/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@ abstract class Processor
{
use Artisan;

abstract public function handle(): void;

public function __construct(
protected Options $options,
protected InputInterface $input,
protected OutputStyle $output,
protected Config $config,
protected Options $options,
protected InputInterface $input,
protected OutputStyle $output,
protected Config $config,
protected ActionRepository $repository,
protected Git $git,
protected File $file,
protected Migrator $migrator,
protected Notification $notification,
protected Dispatcher $events,
protected Sorter $sorter
protected Git $git,
protected File $file,
protected Migrator $migrator,
protected Notification $notification,
protected Dispatcher $events,
protected Sorter $sorter
) {
$this->notification->setOutput($this->output, $this->options->silent);
$this->repository->setConnection($this->options->connection);
$this->migrator->setConnection($this->options->connection)->setOutput($this->output);
}

abstract public function handle(): void;

protected function getFiles(string $path, ?Closure $filter = null): array
{
$file = Str::finish($path, '.php');

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

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

return Arr::of($this->sorter->byValues($files))
->map(fn (string $value) => Str::before($value, '.php'))
Expand Down
17 changes: 17 additions & 0 deletions tests/Commands/MigrateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,4 +652,21 @@ public function testFileExclusion()
$this->assertDatabaseMigrationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz');
$this->assertDatabaseMigrationHas($this->table, 'sub_path/2022_10_27_230732_foo');
}

public function testEmptyDirectory()
{
$this->copyEmptyDirectory();

$table = 'every_time';

$this->artisan(Names::INSTALL)->assertExitCode(0);

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, $table);
$this->artisan(Names::MIGRATE)->assertExitCode(0);

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
}
}
8 changes: 8 additions & 0 deletions tests/Concerns/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ protected function copyFiles(): void
);
}

protected function copyEmptyDirectory(): void
{
File::copyDirectory(
__DIR__ . '/../fixtures/app/empty',
$this->targetDirectory()
);
}

protected function copyDI(): void
{
File::copyDirectory(
Expand Down
Empty file.
Empty file.