-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now PR 703 has unblocked testing of PHPCBF-only code, the `// @codeCoverageIgnore` annotation for this CBF-only code in the `Util\Help` class can be removed and this code can now be tested. This commit adjusts the relevant test method to ensure that the CBF-only code is also tested.
- Loading branch information
Showing
2 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Tests to verify that the "help" command functions as expected. | ||
* | ||
* @author Juliette Reinders Folmer <[email protected]> | ||
* @copyright 2024 Juliette Reinders Folmer. All rights reserved. | ||
* @copyright 2024 PHPCSStandards and contributors | ||
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | ||
*/ | ||
|
||
|
@@ -386,7 +386,7 @@ public static function dataOptionFilteringSpacerHandling() | |
|
||
|
||
/** | ||
* Test that if no short/long options are passed, only usage information is displayed (and displayed correctly). | ||
* Test that if no short/long options are passed, only usage information is displayed (CS mode). | ||
* | ||
* @param array<string> $cliArgs Command line arguments. | ||
* @param string $expectedRegex Regex to validate expected output. | ||
|
@@ -395,15 +395,59 @@ public static function dataOptionFilteringSpacerHandling() | |
* | ||
* @return void | ||
*/ | ||
public function testDisplayUsage($cliArgs, $expectedRegex) | ||
public function testDisplayUsageCS($cliArgs, $expectedRegex) | ||
{ | ||
if (PHP_CODESNIFFER_CBF === true) { | ||
$this->markTestSkipped('This test needs CS mode to run'); | ||
} | ||
|
||
$expectedRegex = str_replace('phpc(bf|s)', 'phpcs', $expectedRegex); | ||
$this->verifyDisplayUsage($cliArgs, $expectedRegex); | ||
|
||
}//end testDisplayUsageCS() | ||
|
||
|
||
/** | ||
* Test that if no short/long options are passed, only usage information is displayed (CBF mode). | ||
* | ||
* @param array<string> $cliArgs Command line arguments. | ||
* @param string $expectedRegex Regex to validate expected output. | ||
* | ||
* @dataProvider dataDisplayUsage | ||
* @group CBF | ||
* | ||
* @return void | ||
*/ | ||
public function testDisplayUsageCBF($cliArgs, $expectedRegex) | ||
{ | ||
if (PHP_CODESNIFFER_CBF === false) { | ||
$this->markTestSkipped('This test needs CBF mode to run'); | ||
} | ||
|
||
$expectedRegex = str_replace('phpc(bf|s)', 'phpcbf', $expectedRegex); | ||
$this->verifyDisplayUsage($cliArgs, $expectedRegex); | ||
|
||
}//end testDisplayUsageCBF() | ||
|
||
|
||
/** | ||
* Helper method to test that if no short/long options are passed, only usage information is displayed | ||
* (and displayed correctly). | ||
* | ||
* @param array<string> $cliArgs Command line arguments. | ||
* @param string $expectedRegex Regex to validate expected output. | ||
* | ||
* @return void | ||
*/ | ||
private function verifyDisplayUsage($cliArgs, $expectedRegex) | ||
{ | ||
$help = new Help(new ConfigDouble($cliArgs), []); | ||
|
||
$this->expectOutputRegex($expectedRegex); | ||
|
||
$help->display(); | ||
|
||
}//end testDisplayUsage() | ||
}//end verifyDisplayUsage() | ||
|
||
|
||
/** | ||
|