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.
Do not prefix built-in PHP classes. Fix #79
- Loading branch information
1 parent
d26e040
commit 1bd20b7
Showing
2 changed files
with
381 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,62 @@ | ||
<?php | ||
/** | ||
* JsonException core PHP class, polyfilled by Symfony, incorrectly replaced | ||
* | ||
* | ||
* | ||
* @see https://github.com/BrianHenryIE/strauss/issues/79 | ||
*/ | ||
|
||
namespace BrianHenryIE\Strauss\Tests\Issues; | ||
|
||
use BrianHenryIE\Strauss\Console\Commands\Compose; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* @package BrianHenryIE\Strauss\Tests\Issues | ||
* @coversNothing | ||
*/ | ||
class StraussIssue79Test extends \BrianHenryIE\Strauss\Tests\Integration\Util\IntegrationTestCase | ||
{ | ||
|
||
/** | ||
*/ | ||
public function test_namespace_keyword_on_opening_line() | ||
{ | ||
|
||
$composerJsonString = <<<'EOD' | ||
{ | ||
"name": "issue/79", | ||
"require": { | ||
"json-mapper/json-mapper": "2.20.0" | ||
}, | ||
"extra": { | ||
"strauss": { | ||
"namespace_prefix": "BrianHenryIE\\Issue79\\", | ||
"classmap_prefix": "BH_Strauss_Issue79_" | ||
} | ||
} | ||
} | ||
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(); | ||
|
||
$result = $strauss->run($inputInterfaceMock, $outputInterfaceMock); | ||
|
||
self::assertEquals(0, $result); | ||
|
||
$php_string = file_get_contents($this->testsWorkingDir . '/vendor-prefixed/json-mapper/json-mapper/src/JsonMapper.php'); | ||
self::assertStringNotContainsString('throw new \BH_Strauss_Issue79_JsonException(json_last_error_msg()', $php_string); | ||
self::assertStringContainsString('throw new \JsonException(json_last_error_msg(), \json_last_error());', $php_string); | ||
} | ||
} |