Skip to content

Commit

Permalink
Merge pull request #1667 from hydephp/update-debug-command
Browse files Browse the repository at this point in the history
Update debug command to print binary path when running in the Phar standalone
  • Loading branch information
caendesilva authored Apr 17, 2024
2 parents e9a4cc2 + c18f45a commit 710c876
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This serves two purposes:
### Changed
- The `features` array in the `config/hyde.php` configuration file is now an array of `Feature` enums in https://github.com/hydephp/develop/pull/1650
- Sitemap generation will now be skipped if a base URL is not set, as Google now will not index sitemaps without a base URL in https://github.com/hydephp/develop/pull/1660
- Updated the debug command to print the binary path when running in a standalone Phar in https://github.com/hydephp/develop/pull/1667

### Deprecated
- Deprecated the static `Features` flag methods used in the configuration files in https://github.com/hydephp/develop/pull/1650 and will be removed in HydePHP v2.0
Expand Down
6 changes: 6 additions & 0 deletions packages/framework/src/Console/Commands/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
use Hyde\Hyde;
use Hyde\Facades\Config;
use Composer\InstalledVersions;
use Hyde\Foundation\PharSupport;
use LaravelZero\Framework\Commands\Command;

use function str_replace;
use function realpath;
use function app;
use function get_included_files;

/**
* Print debug information.
Expand Down Expand Up @@ -50,6 +52,10 @@ public function handle(): int
$this->printVerbosePathInformation();
} else {
$this->comment('Project directory: '.Hyde::path());

if (PharSupport::running()) {
$this->comment('Application binary path: '.get_included_files()[0]);
}
}
$this->newLine();

Expand Down
33 changes: 33 additions & 0 deletions packages/framework/tests/Feature/Commands/DebugCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

namespace Hyde\Framework\Testing\Feature\Commands;

use Mockery;
use Hyde\Testing\TestCase;
use Hyde\Foundation\PharSupport;
use Illuminate\Console\OutputStyle;
use Hyde\Console\Commands\DebugCommand;

/**
* @covers \Hyde\Console\Commands\DebugCommand
Expand Down Expand Up @@ -46,4 +50,33 @@ public function testItPrintsVerboseDebugInformation()
->expectsOutputToContain('(real)')
->assertExitCode(0);
}

public function testItPrintsPharDebugInformation()
{
PharSupport::mock('running', true);

$wasCalled = false;

$output = Mockery::mock(OutputStyle::class, [
'writeln' => null,
'newLine' => null,
'isVerbose' => false,
])->makePartial();

$output->shouldReceive('writeln')->withArgs(function ($message) use (&$wasCalled) {
if (str_contains($message, 'Application binary path:')) {
$wasCalled = true;
}

return true;
});

$command = new DebugCommand();
$command->setOutput($output);
$command->handle();

$this->assertTrue($wasCalled, 'Expected "Application binary path" to be called');

PharSupport::clearMocks();
}
}

0 comments on commit 710c876

Please sign in to comment.