Skip to content
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

test: Refactor shebang creation #1213

Merged
merged 1 commit into from
Nov 26, 2023
Merged
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
19 changes: 12 additions & 7 deletions tests/Console/Command/CompileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function test_it_can_build_a_phar_file(): void
FS::dumpFile('composer.lock', '{}');
FS::dumpFile('vendor/composer/installed.json', '{}');

$shebang = sprintf('#!%s', (new PhpExecutableFinder())->find());
$shebang = self::getExpectedShebang();

$numberOfFiles = self::NUMBER_OF_FILES;

Expand Down Expand Up @@ -355,7 +355,7 @@ public function test_it_can_build_a_phar_from_a_different_directory(): void
{
FS::mirror(self::FIXTURES_DIR.'/dir000', $this->tmp);

$shebang = sprintf('#!%s', (new PhpExecutableFinder())->find());
$shebang = self::getExpectedShebang();

FS::dumpFile(
'box.json',
Expand Down Expand Up @@ -788,7 +788,7 @@ public function test_it_can_build_a_phar_file_in_verbose_mode(): void

FS::mirror(self::FIXTURES_DIR.'/dir000', $this->tmp);

$shebang = sprintf('#!%s', (new PhpExecutableFinder())->find());
$shebang = self::getExpectedShebang();

$expectedNumberOfClasses = 1;
$expectedNumberOfFiles = self::NUMBER_OF_FILES;
Expand Down Expand Up @@ -915,7 +915,7 @@ public function test_it_can_build_a_phar_file_in_very_verbose_mode(): void

FS::mirror(self::FIXTURES_DIR.'/dir000', $this->tmp);

$shebang = sprintf('#!%s', (new PhpExecutableFinder())->find());
$shebang = self::getExpectedShebang();

$expectedNumberOfClasses = 1;
$expectedNumberOfFiles = self::NUMBER_OF_FILES;
Expand Down Expand Up @@ -1315,7 +1315,7 @@ public function test_it_can_build_a_phar_file_in_quiet_mode(): void
{
FS::mirror(self::FIXTURES_DIR.'/dir000', $this->tmp);

$shebang = sprintf('#!%s', (new PhpExecutableFinder())->find());
$shebang = self::getExpectedShebang();

FS::dumpFile(
'box.json',
Expand Down Expand Up @@ -1382,7 +1382,7 @@ public function test_it_can_build_a_phar_file_using_the_phar_default_stub(): voi
{
FS::mirror(self::FIXTURES_DIR.'/dir000', $this->tmp);

$shebang = sprintf('#!%s', (new PhpExecutableFinder())->find());
$shebang = self::getExpectedShebang();

FS::dumpFile(
'box.json',
Expand Down Expand Up @@ -1431,7 +1431,7 @@ public function test_it_can_build_a_phar_file_using_a_custom_stub(): void
{
FS::mirror(self::FIXTURES_DIR.'/dir000', $this->tmp);

$shebang = sprintf('#!%s', (new PhpExecutableFinder())->find());
$shebang = self::getExpectedShebang();

FS::dumpFile(
'custom_stub',
Expand Down Expand Up @@ -3143,4 +3143,9 @@ private function skipIfDefaultStubNotFound(): void
self::markTestSkipped('The default stub file could not be found. Run the tests via the make commands or manually generate the stub file with `$ make generate_default_stub`.');
}
}

private static function getExpectedShebang(): string
{
return sprintf('#!%s', (new PhpExecutableFinder())->find());
}
}
Loading