Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/Commands/OneTimeOperationsMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function handle(): int
{
try {
$file = OneTimeOperationCreator::createOperationFile($this->argument('name'), $this->option('essential'));
$this->components->info(sprintf('One-time operation [%s] created successfully.', $file->getOperationName()));
$this->components->info(sprintf('One-time operation [%s] created successfully.', $file->getOperationFilePath()));

return self::SUCCESS;
} catch (Throwable $e) {
Expand Down
5 changes: 5 additions & 0 deletions src/OneTimeOperationFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public function getOperationName(): string
return Str::remove('.php', $filename);
}

public function getOperationFilePath(): string
{
return $this->file->getRealPath();
}

public function getClassObject(): OneTimeOperation
{
if (! $this->classObject) {
Expand Down
9 changes: 7 additions & 2 deletions tests/Feature/OneTimeOperationCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function test_make_command_with_attributes()
// create operation file
$this->artisan('operations:make AwesomeOperation')
->assertSuccessful()
->expectsOutputToContain('One-time operation [2015_10_21_072800_awesome_operation] created successfully.');
->expectsOutputToContain(sprintf('One-time operation [%s] created successfully.', $this->fileRealPath($filepath)));

// file was created, but no operation entry yet
$this->assertFileExists($filepath);
Expand Down Expand Up @@ -86,7 +86,7 @@ public function test_the_whole_command_process()
// create operation file
$this->artisan('operations:make AwesomeOperation')
->assertSuccessful()
->expectsOutputToContain('One-time operation [2015_10_21_072800_awesome_operation] created successfully.');
->expectsOutputToContain(sprintf('One-time operation [%s] created successfully.', $this->fileRealPath($filepath)));

// file was created, but no operation entry yet
$this->assertFileExists($filepath);
Expand Down Expand Up @@ -433,6 +433,11 @@ protected function filepath(string $filename): string
return base_path(config('one-time-operations.directory')).DIRECTORY_SEPARATOR.$filename;
}

protected function fileRealPath(string $filepath): string
{
return realpath('.').DIRECTORY_SEPARATOR.Str::afterLast($filepath, '../');
}

protected function tearDown(): void
{
File::deleteDirectory(base_path(config('one-time-operations.directory')));
Expand Down
1 change: 1 addition & 0 deletions tests/Feature/OneTimeOperationCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function it_creates_an_operation_file_instance()
$this->assertInstanceOf(OneTimeOperationFile::class, $operationFile);
$this->assertInstanceOf(OneTimeOperation::class, $operationFile->getClassObject());
$this->assertEquals('2015_10_21_072800_test_operation', $operationFile->getOperationName());
$this->assertStringContainsString('tests/files/2015_10_21_072800_test_operation.php', $operationFile->getOperationFilePath());

File::delete($filepath);
}
Expand Down