Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-detect phpcs in vendor directory #81

Merged
merged 9 commits into from
May 20, 2023
Prev Previous commit
Next Next commit
Register exeutables for SvnWorkflowTest
  • Loading branch information
sirbrillig committed May 20, 2023
commit 87dc4a1fce80501536625b43ef6df0157bbf154f
75 changes: 75 additions & 0 deletions tests/SvnWorkflowTest.php
Original file line number Diff line number Diff line change
@@ -72,6 +72,9 @@ public function testFullSvnWorkflowForOneFile() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("svn cat 'foobar.php' | phpcs", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -90,6 +93,9 @@ public function testFullSvnWorkflowForOneFileWithReplacedSvn() {
'svn-path' => $svnPath,
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable($svnPath);
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("{$svnPath} diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("{$svnPath} info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("{$svnPath} cat 'foobar.php' | phpcs", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -108,6 +114,9 @@ public function testFullSvnWorkflowForOneFileWithReplacedCat() {
'cat-path' => $catPath,
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable($catPath);
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("svn cat 'foobar.php' | phpcs", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -126,6 +135,9 @@ public function testFullSvnWorkflowForOneFileWithReplacedPhpcs() {
'phpcs-path' => $phpcsPath,
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable($phpcsPath);
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("svn cat 'foobar.php' | {$phpcsPath}", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -142,6 +154,9 @@ public function testFullSvnWorkflowForOneFileWithNoMessages() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("cat 'foobar.php'", $this->phpcs->getEmptyResults()->toPhpcsJson());
@@ -159,6 +174,9 @@ public function testFullSvnWorkflowForOneFileWithCachingEnabledButNoCache() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("svn cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -176,6 +194,9 @@ public function testFullSvnWorkflowForOneFileWithOldFileCached() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php', '188280'));
$shell->registerCommand("cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 21])->toPhpcsJson());
@@ -196,6 +217,9 @@ public function testFullSvnWorkflowForOneFileUncachedThenCachesBothVersionsOfThe
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php', '188280'));
$shell->registerCommand("svn cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -223,6 +247,9 @@ public function testFullSvnWorkflowForOneDoesNotUseNewFileCacheWhenHashChanges()
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php', '188280'));
$shell->registerCommand("svn cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -261,6 +288,9 @@ public function testFullSvnWorkflowForOneClearsCacheForFileWhenHashChanges() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php', '188280'));
$shell->registerCommand("svn cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -307,6 +337,9 @@ public function testFullSvnWorkflowForOneDoesNotClearCacheWhenStandardChanges()
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php', '188280'));
$shell->registerCommand("svn cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -354,6 +387,9 @@ public function testFullSvnWorkflowForOneFileUncachedWhenCachingIsDisabled() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("svn cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -375,6 +411,9 @@ public function testFullSvnWorkflowForOneFileWithOldCacheVersion() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php', '188280'));
$shell->registerCommand("svn cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -398,6 +437,9 @@ public function testFullSvnWorkflowForOneFileWithCacheThatHasDifferentStandard()
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php', '188280'));
$oldFileOutput = $this->phpcs->getResults('STDIN', [20, 99]);
@@ -421,6 +463,9 @@ public function testFullSvnWorkflowForOneFileWithCacheOfOldFileVersionDoesNotUse
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
$shell->registerCommand("cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 21])->toPhpcsJson());
@@ -449,6 +494,9 @@ public function testFullSvnWorkflowForUnchangedFileWithBothFilesCached() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getEmptyFileDiff());
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php', '188280'));
$shell->registerCommand("cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 21])->toPhpcsJson());
@@ -470,6 +518,9 @@ public function testFullSvnWorkflowForUnchangedFileWithOldFileCached() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getEmptyFileDiff());
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php', '188280'));
$shell->registerCommand("cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 21])->toPhpcsJson());
@@ -489,6 +540,9 @@ public function testFullSvnWorkflowForMultipleFiles() {
'files' => $svnFiles,
]);
$shell = new TestShell($options, $svnFiles);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn diff 'baz.php'", $this->fixture->getAddedLineDiff('baz.php', 'use Baz;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
@@ -514,6 +568,9 @@ public function testFullSvnWorkflowForUnchangedFileWithPhpCsMessages() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getEmptyFileDiff());
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("svn cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -530,6 +587,9 @@ public function testFullSvnWorkflowForUnchangedFileWithoutPhpCsMessages() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getEmptyFileDiff());
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("svn cat 'foobar.php'", '{"totals":{"errors":0,"warnings":0,"fixable":0},"files":{"STDIN":{"errors":0,"warnings":0,"messages":[]}}}');
@@ -546,6 +606,9 @@ public function testFullSvnWorkflowForChangedFileWithoutPhpCsMessagesLintsOnlyNe
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getEmptyFileDiff());
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("svn cat 'foobar.php'", '{"totals":{"errors":0,"warnings":0,"fixable":0},"files":{"STDIN":{"errors":0,"warnings":0,"messages":[]}}}');
@@ -564,6 +627,9 @@ public function testFullSvnWorkflowForNonSvnFile() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getNonSvnFileDiff('foobar.php'), 1);
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfoNonSvnFile('foobar.php'), 1);
$shell->registerCommand("svn cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());
@@ -578,6 +644,9 @@ public function testFullSvnWorkflowForNewFile() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getNewFileDiff('foobar.php'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfoNewFile('foobar.php'));
$shell->registerCommand("cat 'foobar.php'", $this->phpcs->getResults('STDIN', [20, 21])->toPhpcsJson());
@@ -593,6 +662,9 @@ public function testFullSvnWorkflowForEmptyNewFile() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getNewFileDiff('foobar.php'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfoNewFile('foobar.php'));
$fixture = 'ERROR: You must supply at least one file or directory to process.
@@ -616,6 +688,9 @@ public function testFullSvnWorkflowForOneFileWithSeveritySetToZero() {
'files' => [$svnFile],
]);
$shell = new TestShell($options, [$svnFile]);
$shell->registerExecutable('svn');
$shell->registerExecutable('phpcs');
$shell->registerExecutable('cat');
$shell->registerCommand("svn diff 'foobar.php'", $this->fixture->getAddedLineDiff('foobar.php', 'use Foobar;'));
$shell->registerCommand("svn info 'foobar.php'", $this->fixture->getSvnInfo('foobar.php'));
$shell->registerCommand("svn cat 'foobar.php' | phpcs --report=json -q --standard='standard' --warning-severity='0' --error-severity='0'", $this->phpcs->getResults('STDIN', [20, 99])->toPhpcsJson());