FEATURE: Allow multiple files to be used as insert for tests
* Detect file for php and TS out of the box. * Keep old handling to configure file name. * Also detect file format, e.g. TypoScript, and configure phpcs tokenizer accordingly. Relates: #54
This commit is contained in:
parent
7a999212e2
commit
154fe43582
1 changed files with 38 additions and 6 deletions
|
@ -114,6 +114,12 @@ class SniffsTest extends TestCase
|
|||
*/
|
||||
protected function executeSniff(\SplFileInfo $folder, array $arguments = [])
|
||||
{
|
||||
$fileName = '';
|
||||
if (isset($arguments['inputFileName'])) {
|
||||
$fileName = $arguments['inputFileName'];
|
||||
unset($arguments['inputFileName']);
|
||||
}
|
||||
|
||||
$internalArguments = array_merge_recursive([
|
||||
'standard' => 'Typo3Update',
|
||||
'runtime-set' => [
|
||||
|
@ -123,14 +129,11 @@ class SniffsTest extends TestCase
|
|||
],
|
||||
'report' => 'json',
|
||||
'sniffs' => $this->getSniffByFolder($folder),
|
||||
'inputFile' => $folder->getRealPath() . DIRECTORY_SEPARATOR . 'InputFileForIssues.php',
|
||||
'inputFile' => $this->getInputFile($folder, $fileName),
|
||||
], $arguments);
|
||||
|
||||
if (isset($internalArguments['inputFileName'])) {
|
||||
$internalArguments['inputFile'] = $folder->getRealPath()
|
||||
. DIRECTORY_SEPARATOR
|
||||
. $internalArguments['inputFileName'];
|
||||
unset($internalArguments['inputFileName']);
|
||||
if (strpos($internalArguments['inputFile'], '.ts') !== false) {
|
||||
$internalArguments['extensions'] = 'ts/TypoScript';
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -229,6 +232,35 @@ class SniffsTest extends TestCase
|
|||
return $folder->getRealPath() . DIRECTORY_SEPARATOR . 'Arguments.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get absolute file path to file to use for testing.
|
||||
*
|
||||
* @param \SplFileInfo $folder
|
||||
* @param string $fileName
|
||||
* @return string
|
||||
*/
|
||||
protected function getInputFile(\SplFileInfo $folder, $fileName = '')
|
||||
{
|
||||
$folderPath = $folder->getRealPath() . DIRECTORY_SEPARATOR;
|
||||
$file = $folderPath . $fileName;
|
||||
|
||||
if (!is_file($file)) {
|
||||
$file = $folderPath . $fileName;
|
||||
}
|
||||
if (!is_file($file)) {
|
||||
$file = $folderPath . 'InputFileForIssues.php';
|
||||
}
|
||||
if (!is_file($file)) {
|
||||
$file = $folderPath . 'InputFileForIssues.ts';
|
||||
}
|
||||
|
||||
if (!is_file($file)) {
|
||||
throw new \Exception('message', 1492083289);
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build cli call for phpcs.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue