33 * Tests to verify that the "help" command functions as expected.
44 *
55 * @author Juliette Reinders Folmer <[email protected] > 6- * @copyright 2024 Juliette Reinders Folmer. All rights reserved.
6+ * @copyright 2024 PHPCSStandards and contributors
77 * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
88 */
99
@@ -386,7 +386,7 @@ public static function dataOptionFilteringSpacerHandling()
386386
387387
388388 /**
389- * Test that if no short/long options are passed, only usage information is displayed (and displayed correctly ).
389+ * Test that if no short/long options are passed, only usage information is displayed (CS mode ).
390390 *
391391 * @param array<string> $cliArgs Command line arguments.
392392 * @param string $expectedRegex Regex to validate expected output.
@@ -395,15 +395,59 @@ public static function dataOptionFilteringSpacerHandling()
395395 *
396396 * @return void
397397 */
398- public function testDisplayUsage ($ cliArgs , $ expectedRegex )
398+ public function testDisplayUsageCS ($ cliArgs , $ expectedRegex )
399+ {
400+ if (PHP_CODESNIFFER_CBF === true ) {
401+ $ this ->markTestSkipped ('This test needs CS mode to run ' );
402+ }
403+
404+ $ expectedRegex = str_replace ('phpc(bf|s) ' , 'phpcs ' , $ expectedRegex );
405+ $ this ->verifyDisplayUsage ($ cliArgs , $ expectedRegex );
406+
407+ }//end testDisplayUsageCS()
408+
409+
410+ /**
411+ * Test that if no short/long options are passed, only usage information is displayed (CBF mode).
412+ *
413+ * @param array<string> $cliArgs Command line arguments.
414+ * @param string $expectedRegex Regex to validate expected output.
415+ *
416+ * @dataProvider dataDisplayUsage
417+ * @group CBF
418+ *
419+ * @return void
420+ */
421+ public function testDisplayUsageCBF ($ cliArgs , $ expectedRegex )
422+ {
423+ if (PHP_CODESNIFFER_CBF === false ) {
424+ $ this ->markTestSkipped ('This test needs CBF mode to run ' );
425+ }
426+
427+ $ expectedRegex = str_replace ('phpc(bf|s) ' , 'phpcbf ' , $ expectedRegex );
428+ $ this ->verifyDisplayUsage ($ cliArgs , $ expectedRegex );
429+
430+ }//end testDisplayUsageCBF()
431+
432+
433+ /**
434+ * Helper method to test that if no short/long options are passed, only usage information is displayed
435+ * (and displayed correctly).
436+ *
437+ * @param array<string> $cliArgs Command line arguments.
438+ * @param string $expectedRegex Regex to validate expected output.
439+ *
440+ * @return void
441+ */
442+ private function verifyDisplayUsage ($ cliArgs , $ expectedRegex )
399443 {
400444 $ help = new Help (new ConfigDouble ($ cliArgs ), []);
401445
402446 $ this ->expectOutputRegex ($ expectedRegex );
403447
404448 $ help ->display ();
405449
406- }//end testDisplayUsage ()
450+ }//end verifyDisplayUsage ()
407451
408452
409453 /**
0 commit comments