Skip to content

Commit

Permalink
test: Refactor shebang creation
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Nov 26, 2023
1 parent 21fb7c7 commit 79630c4
Showing 1 changed file with 12 additions and 7 deletions.
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());
}
}

0 comments on commit 79630c4

Please sign in to comment.