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

Fix no-vendor-phpcs flag #92

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PhpcsChanged/CliOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static function fromArray(array $options): self {
$cliOptions->files = $options['files'];
}
if (isset($options['no-vendor-phpcs'])) {
$cliOptions->noVendorPhpcs = $options['no-vendor-phpcs'];
$cliOptions->noVendorPhpcs = true;
}
if (isset($options['phpcs-path'])) {
$cliOptions->phpcsPath = $options['phpcs-path'];
Expand Down
70 changes: 35 additions & 35 deletions tests/GitWorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function setUp(): void {

public function testFullGitWorkflowForOneFileStaged() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-staged' => 1, 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-staged' => false, 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand All @@ -48,8 +48,8 @@ public function testFullGitWorkflowForOneFileStagedWithReplacedGit() {
$gitFile = 'foobar.php';
$gitPath = 'bin/foo/git';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-staged' => 1,
'no-cache-git-root' => false,
'git-staged' => false,
'files' => [$gitFile],
'git-path' => $gitPath,
]);
Expand All @@ -73,8 +73,8 @@ public function testFullGitWorkflowForOneFileStagedWithReplacedPhpcs() {
$gitFile = 'foobar.php';
$phpcsPath = 'bin/foo/phpcs';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-staged' => 1,
'no-cache-git-root' => false,
'git-staged' => false,
'files' => [$gitFile],
'phpcs-path' => $phpcsPath,
]);
Expand All @@ -98,8 +98,8 @@ public function testFullGitWorkflowForOneFileStagedWithVendorDefaultPhpcs() {
$gitFile = 'foobar.php';
$phpcsPath = 'vendor/bin/phpcs';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-staged' => 1,
'no-cache-git-root' => false,
'git-staged' => false,
'files' => [$gitFile],
]);
$shell = new TestShell($options, [$gitFile]);
Expand All @@ -122,10 +122,10 @@ public function testFullGitWorkflowForOneFileStagedWithNoVendorDefaultPhpcs() {
$gitFile = 'foobar.php';
$phpcsPath = 'vendor/bin/phpcs';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-staged' => 1,
'no-cache-git-root' => false, // getopt is weird and sets options to false
'git-staged' => false, // getopt is weird and sets options to false
'files' => [$gitFile],
'no-vendor-phpcs' => true,
'no-vendor-phpcs' => false, // getopt is weird and sets options to false
]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
Expand All @@ -146,7 +146,7 @@ public function testFullGitWorkflowForOneFileStagedWithNoVendorDefaultPhpcs() {

public function testFullGitWorkflowForOneFileUnstaged() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-unstaged' => '1', 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-unstaged' => false, 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand All @@ -166,8 +166,8 @@ public function testFullGitWorkflowForOneFileUnstaged() {
public function testFullGitWorkflowForOneChangedFileWithoutPhpcsMessagesLintsOnlyNewFile() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-unstaged' => '1',
'no-cache-git-root' => false,
'git-unstaged' => false,
'files' => [$gitFile],
]);
$shell = new TestShell($options, [$gitFile]);
Expand All @@ -190,8 +190,8 @@ public function testFullGitWorkflowForOneChangedFileWithoutPhpcsMessagesLintsOnl
public function testFullGitWorkflowForOneFileUnstagedCachesDataThenUsesCache() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-unstaged' => '1',
'no-cache-git-root' => false,
'git-unstaged' => false,
'cache' => false, // getopt is weird and sets options to false
'files' => [$gitFile],
]);
Expand Down Expand Up @@ -222,8 +222,8 @@ public function testFullGitWorkflowForOneFileUnstagedCachesDataThenUsesCache() {
public function testFullGitWorkflowForOneFileUnstagedCachesDataThenUsesCacheWithSeveritySet() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-unstaged' => '1',
'no-cache-git-root' => false,
'git-unstaged' => false,
'cache' => false, // getopt is weird and sets options to false
'standard' => 'standard',
'warning-severity' => '1',
Expand Down Expand Up @@ -262,8 +262,8 @@ public function testFullGitWorkflowForOneFileUnstagedCachesDataThenUsesCacheWith
public function testFullGitWorkflowForOneFileUnstagedCachesDataThenUsesCacheWithSeveritySetToZero() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-unstaged' => '1',
'no-cache-git-root' => false,
'git-unstaged' => false,
'cache' => false, // getopt is weird and sets options to false
'standard' => 'standard',
'warning-severity' => '0',
Expand Down Expand Up @@ -304,8 +304,8 @@ public function testFullGitWorkflowForOneFileUnstagedCachesDataThenUsesCacheWith
public function testFullGitWorkflowForOneFileUnstagedCachesDataThenUsesCacheWithSeverityNotSet() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-unstaged' => '1',
'no-cache-git-root' => false,
'git-unstaged' => false,
'cache' => false, // getopt is weird and sets options to false
'standard' => 'standard',
'files' => [$gitFile],
Expand Down Expand Up @@ -344,8 +344,8 @@ public function testFullGitWorkflowForOneFileUnstagedCachesDataThenUsesCacheWith
public function testFullGitWorkflowForOneFileUnstagedCachesDataThenClearsOldCacheWhenOldFileChanges() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-unstaged' => '1',
'no-cache-git-root' => false,
'git-unstaged' => false,
'cache' => false, // getopt is weird and sets options to false
'files' => [$gitFile],
]);
Expand Down Expand Up @@ -378,8 +378,8 @@ public function testFullGitWorkflowForOneFileUnstagedCachesDataThenClearsOldCach
public function testFullGitWorkflowForOneFileUnstagedCachesDataThenClearsNewCacheWhenFileChanges() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray([
'no-cache-git-root' => 1,
'git-unstaged' => '1',
'no-cache-git-root' => false,
'git-unstaged' => false,
'cache' => false, // getopt is weird and sets options to false
'files' => [$gitFile],
]);
Expand Down Expand Up @@ -411,7 +411,7 @@ public function testFullGitWorkflowForOneFileUnstagedCachesDataThenClearsNewCach

public function testFullGitWorkflowForMultipleFilesStaged() {
$gitFiles = ['foobar.php', 'baz.php'];
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-staged' => 1, 'files' => $gitFiles]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-staged' => false, 'files' => $gitFiles]);
$shell = new TestShell($options, $gitFiles);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand Down Expand Up @@ -439,7 +439,7 @@ public function testFullGitWorkflowForMultipleFilesStaged() {

public function testFullGitWorkflowForUnchangedFileWithPhpcsMessages() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-staged' => 1, 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-staged' => false, 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand All @@ -458,7 +458,7 @@ public function testFullGitWorkflowForUnchangedFileWithPhpcsMessages() {

public function testFullGitWorkflowForUnchangedFileWithoutPhpcsMessages() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-staged' => 1, 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-staged' => false, 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand All @@ -476,7 +476,7 @@ public function testFullGitWorkflowForUnchangedFileWithoutPhpcsMessages() {
public function testFullGitWorkflowForNonGitFile() {
$this->expectException(ShellException::class);
$gitFile = 'foobar.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-staged' => 1, 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-staged' => false, 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand All @@ -493,7 +493,7 @@ public function testFullGitWorkflowForNonGitFile() {

public function testFullGitWorkflowForNewFile() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-staged' => 1, 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-staged' => false, 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand All @@ -511,7 +511,7 @@ public function testFullGitWorkflowForNewFile() {

public function testFullGitWorkflowForEmptyNewFile() {
$gitFile = 'foobar.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-staged' => 1, 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-staged' => false, 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand All @@ -534,7 +534,7 @@ public function testFullGitWorkflowForEmptyNewFile() {

public function testFullGitWorkflowForInterBranchDiff() {
$gitFile = 'bin/foobar.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-base' => 'master', 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-base' => 'master', 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand All @@ -557,7 +557,7 @@ public function testFullGitWorkflowForInterBranchDiff() {

public function testFullGitWorkflowForUnchangedFileForInterBranchDiff() {
$gitFile = 'bin/foobar.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-base' => 'master', 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-base' => 'master', 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand All @@ -578,7 +578,7 @@ public function testFullGitWorkflowForUnchangedFileForInterBranchDiff() {

public function testFullGitWorkflowWithUntrackedFileForInterBranchDiff() {
$gitFile = 'bin/foobar.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-base' => 'master', 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-base' => 'master', 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand All @@ -601,7 +601,7 @@ public function testFullGitWorkflowWithUntrackedFileForInterBranchDiff() {

public function testNameDetectionInFullGitWorkflowForInterBranchDiff() {
$gitFile = 'test.php';
$options = CliOptions::fromArray(['no-cache-git-root' => 1, 'git-base' => 'master', 'files' => [$gitFile]]);
$options = CliOptions::fromArray(['no-cache-git-root' => false, 'git-base' => 'master', 'files' => [$gitFile]]);
$shell = new TestShell($options, [$gitFile]);
$shell->registerExecutable('git');
$shell->registerExecutable('phpcs');
Expand Down
Loading