forked from coenjacobs/mozart
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: incorrect order of
str_starts_with()
- Loading branch information
1 parent
fad97d4
commit ccac6af
Showing
2 changed files
with
82 additions
and
1 deletion.
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,81 @@ | ||
<?php | ||
/** | ||
* Don't double prefix when updating project code on repeated runs. | ||
* | ||
* @see https://github.com/BrianHenryIE/strauss/issues/34 | ||
*/ | ||
|
||
namespace BrianHenryIE\Strauss\Tests\Issues; | ||
|
||
use BrianHenryIE\Strauss\Composer\Extra\StraussConfig; | ||
use BrianHenryIE\Strauss\Console\Commands\Compose; | ||
use BrianHenryIE\Strauss\Prefixer; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* @package BrianHenryIE\Strauss\Tests\Issues | ||
* @coversNothing | ||
*/ | ||
class StraussIssue34Test extends \BrianHenryIE\Strauss\Tests\Integration\Util\IntegrationTestCase | ||
{ | ||
|
||
public function test_no_double_prefix_after_second_run() | ||
{ | ||
$composerJsonString = <<<'EOD' | ||
{ | ||
"name": "brianhenryie/strauss-34", | ||
"minimum-stability": "dev", | ||
"autoload": { | ||
"classmap": [ | ||
"src/" | ||
] | ||
}, | ||
"require": { | ||
"psr/log": "*" | ||
}, | ||
"extra": { | ||
"strauss": { | ||
"namespace_prefix": "BrianHenryIE\\Strauss\\", | ||
"classmap_prefix": "BH_Strauss_", | ||
"target_directory": "vendor", | ||
"update_call_sites": true | ||
} | ||
} | ||
} | ||
EOD; | ||
$phpFileJsonString = <<<'EOD' | ||
<?php | ||
namespace My_Namespace\My_Project; | ||
use Psr\Log\LoggerInterface; | ||
EOD; | ||
|
||
file_put_contents($this->testsWorkingDir . 'composer.json', $composerJsonString); | ||
@mkdir($this->testsWorkingDir . 'src'); | ||
file_put_contents($this->testsWorkingDir . 'src/library.php', $phpFileJsonString); | ||
|
||
chdir($this->testsWorkingDir); | ||
|
||
exec('composer install'); | ||
|
||
$inputInterfaceMock = $this->createMock(InputInterface::class); | ||
$outputInterfaceMock = $this->createMock(OutputInterface::class); | ||
|
||
$strauss = new Compose(); | ||
|
||
// Run TWICE! | ||
$strauss->run($inputInterfaceMock, $outputInterfaceMock); | ||
$result = $strauss->run($inputInterfaceMock, $outputInterfaceMock); | ||
$this->assertNotEquals(1, $result); | ||
|
||
$project_file_php_string = file_get_contents($this->testsWorkingDir . 'src/library.php'); | ||
self::assertStringNotContainsString('use Psr\Log\LoggerInterface', $project_file_php_string); | ||
self::assertStringContainsString('use BrianHenryIE\Strauss\Psr\Log\LoggerInterface', $project_file_php_string); | ||
|
||
$project_file_php_string = file_get_contents($this->testsWorkingDir . 'vendor/psr/log/src/LoggerInterface.php'); | ||
self::assertStringNotContainsString('namespace Psr\Log;', $project_file_php_string); | ||
self::assertStringContainsString('namespace BrianHenryIE\Strauss\Psr\Log;', $project_file_php_string); | ||
} | ||
} |