Skip to content

Commit 3c4f4be

Browse files
authored
Merge pull request #1105 from fredden/tests/skip-when-git-not-available
Skip tests when 'git' command is not available
2 parents c9858b6 + 353bfde commit 3c4f4be

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tests/Core/Filters/GitModifiedTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace PHP_CodeSniffer\Tests\Core\Filters;
1111

12+
use PHP_CodeSniffer\Config;
1213
use PHP_CodeSniffer\Filters\GitModified;
1314
use PHP_CodeSniffer\Tests\Core\Filters\AbstractFilterTestCase;
1415
use RecursiveArrayIterator;
@@ -219,6 +220,10 @@ public function testExecAlwaysReturnsArray($cmd, $expected)
219220
$this->markTestSkipped('Not a git repository');
220221
}
221222

223+
if (Config::getExecutablePath('git') === null) {
224+
$this->markTestSkipped('git command not available');
225+
}
226+
222227
$fakeDI = new RecursiveArrayIterator(self::getFakeFileList());
223228
$filter = new GitModified($fakeDI, '/', self::$config, self::$ruleset);
224229

tests/Core/Filters/GitStagedTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace PHP_CodeSniffer\Tests\Core\Filters;
1111

12+
use PHP_CodeSniffer\Config;
1213
use PHP_CodeSniffer\Filters\GitStaged;
1314
use PHP_CodeSniffer\Tests\Core\Filters\AbstractFilterTestCase;
1415
use RecursiveArrayIterator;
@@ -219,6 +220,10 @@ public function testExecAlwaysReturnsArray($cmd, $expected)
219220
$this->markTestSkipped('Not a git repository');
220221
}
221222

223+
if (Config::getExecutablePath('git') === null) {
224+
$this->markTestSkipped('git command not available');
225+
}
226+
222227
$fakeDI = new RecursiveArrayIterator(self::getFakeFileList());
223228
$filter = new GitStaged($fakeDI, '/', self::$config, self::$ruleset);
224229

0 commit comments

Comments
 (0)