forked from coenjacobs/mozart
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup
installed.json
after deleting files
- Loading branch information
1 parent
f72148e
commit f53236b
Showing
3 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* Strauss does not remove namespaced classes from the composer classmap files when optimize-autoloader is enabled | ||
* | ||
* @see https://github.com/BrianHenryIE/strauss/issues/87 | ||
*/ | ||
|
||
namespace BrianHenryIE\Strauss\Tests\Issues; | ||
|
||
use BrianHenryIE\Strauss\Console\Commands\Compose; | ||
use BrianHenryIE\Strauss\Tests\Integration\Util\IntegrationTestCase; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* @package BrianHenryIE\Strauss\Tests\Issues | ||
* @coversNothing | ||
*/ | ||
class StraussIssue87Test extends IntegrationTestCase | ||
{ | ||
public function test_autoload_classmap() | ||
{ | ||
|
||
$composerJsonString = <<<'EOD' | ||
{ | ||
"require": { | ||
"psr/container": "^1.1" | ||
}, | ||
"extra": { | ||
"strauss": { | ||
"target_directory": "vendor-prefixed", | ||
"classmap_prefix": "Class_Prefix_", | ||
"constant_prefix": "Constant_", | ||
"namespace_prefix": "New\\Namespace", | ||
"delete_vendor_files": true, | ||
"packages": [ | ||
"psr/container" | ||
] | ||
} | ||
} | ||
} | ||
EOD; | ||
|
||
chdir($this->testsWorkingDir); | ||
|
||
file_put_contents($this->testsWorkingDir . '/composer.json', $composerJsonString); | ||
|
||
exec('composer install'); | ||
exec('composer dump-autoload --optimize'); | ||
|
||
$autoload_classmap_php_string = file_get_contents($this->testsWorkingDir . '/vendor/composer/autoload_classmap.php'); | ||
self::assertStringContainsString("'Psr\\\\Container\\\\ContainerExceptionInterface' => \$vendorDir . '/psr/container/src/ContainerExceptionInterface.php',", $autoload_classmap_php_string); | ||
|
||
$inputInterfaceMock = $this->createMock(InputInterface::class); | ||
$outputInterfaceMock = $this->createMock(OutputInterface::class); | ||
|
||
$strauss = new Compose(); | ||
|
||
$result = $strauss->run($inputInterfaceMock, $outputInterfaceMock); | ||
|
||
exec('composer dump-autoload'); | ||
|
||
$autoload_classmap_php_string = file_get_contents($this->testsWorkingDir . '/vendor/composer/autoload_classmap.php'); | ||
self::assertStringNotContainsString("'Psr\\\\Container\\\\ContainerExceptionInterface' => \$vendorDir . '/psr/container/src/ContainerExceptionInterface.php',", $autoload_classmap_php_string); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* Cleanup vendor/composer/installed.json after delete-vendor-directories | ||
* | ||
* @see https://github.com/BrianHenryIE/strauss/issues/93#issuecomment-2043919370 | ||
*/ | ||
|
||
namespace BrianHenryIE\Strauss\Tests\Issues; | ||
|
||
use BrianHenryIE\Strauss\Console\Commands\Compose; | ||
use BrianHenryIE\Strauss\Tests\Integration\Util\IntegrationTestCase; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* @package BrianHenryIE\Strauss\Tests\Issues | ||
* @coversNothing | ||
*/ | ||
class StraussIssue93Test extends IntegrationTestCase | ||
{ | ||
public function test_removes_entries_from_installed_json() | ||
{ | ||
$composerJsonString = <<<'EOD' | ||
{ | ||
"name": "strauss/issue93", | ||
"require": { | ||
"symfony/polyfill-php80": "v1.29.0" | ||
}, | ||
"extra": { | ||
"strauss": { | ||
"namespace_prefix": "Strauss\\Issue93\\", | ||
"delete_vendor_files": true | ||
} | ||
} | ||
} | ||
EOD; | ||
|
||
chdir($this->testsWorkingDir); | ||
|
||
file_put_contents($this->testsWorkingDir . '/composer.json', $composerJsonString); | ||
|
||
exec('composer install'); | ||
|
||
$inputInterfaceMock = $this->createMock(InputInterface::class); | ||
$outputInterfaceMock = $this->createMock(OutputInterface::class); | ||
|
||
$strauss = new Compose(); | ||
|
||
$strauss->run($inputInterfaceMock, $outputInterfaceMock); | ||
|
||
exec('composer dump-autoload', $output, $result_code); | ||
|
||
self::assertEquals(0, $result_code); | ||
} | ||
} |