BUGFIX: Allow multiple runtime-set per test

Relates: #46
This commit is contained in:
Daniel Siepmann 2017-04-06 16:11:29 +02:00
parent e957e5fe18
commit 0b21535f87
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
3 changed files with 20 additions and 12 deletions

View file

@ -22,6 +22,8 @@
return [ return [
'defaultVendor' => [], 'defaultVendor' => [],
'customVendor' => [ 'customVendor' => [
'runtime-set' => 'vendor MyCustomVendor', 'runtime-set' => [
'vendor' => 'MyCustomVendor',
],
], ],
]; ];

View file

@ -22,6 +22,8 @@
return [ return [
'defaultVendor' => [], 'defaultVendor' => [],
'customVendor' => [ 'customVendor' => [
'runtime-set' => 'vendor MyCustomVendor', 'runtime-set' => [
'vendor' => 'MyCustomVendor',
],
], ],
]; ];

View file

@ -88,11 +88,12 @@ class SniffsTest extends TestCase
*/ */
protected function executeSniff(SplFileInfo $folder, array $arguments = []) protected function executeSniff(SplFileInfo $folder, array $arguments = [])
{ {
$internalArguments = array_merge([ $internalArguments = array_merge_recursive([
'runtime-set' => 'mappingFile ' 'runtime-set' => [
. __DIR__ . DIRECTORY_SEPARATOR 'mappingFile' => __DIR__ . DIRECTORY_SEPARATOR
. 'Fixtures' . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR
. 'LegacyClassnames.php', . 'LegacyClassnames.php',
],
'report' => 'json', 'report' => 'json',
'sniffs' => $this->getSniffByFolder($folder), 'sniffs' => $this->getSniffByFolder($folder),
'inputFile' => $folder->getRealPath() . DIRECTORY_SEPARATOR . 'InputFileForIssues.php', 'inputFile' => $folder->getRealPath() . DIRECTORY_SEPARATOR . 'InputFileForIssues.php',
@ -217,12 +218,15 @@ class SniffsTest extends TestCase
continue; continue;
} }
$prefix = "--$argumentName="; if ($argumentName === 'runtime-set') {
if (in_array($argumentName, ['runtime-set'])) { foreach ($argumentValue as $runtimeName => $runtimeValue) {
$prefix = "--$argumentName "; $preparedArguments[] = "--$argumentName $runtimeName $runtimeValue";
}
continue;
} }
$preparedArguments[] = "$prefix$argumentValue"; $preparedArguments[] = "--$argumentName=$argumentValue";
} }
return $bin return $bin
@ -249,7 +253,7 @@ class SniffsTest extends TestCase
} catch (\Exception $e) { } catch (\Exception $e) {
throw new \Exception( throw new \Exception(
'Error during preparing json output by invoking ' 'Error during preparing json output by invoking '
. $this->getPhpcsCall($arguments) . ' ' . $output, . $this->getPhpcsCall($arguments) . ' ' . $e->getMessage(),
1491487079 1491487079
); );
} }