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
@@ -378,7 +378,7 @@ public static function dataOptionFilteringSpacerHandling()
378378
379379
380380 /**
381- * Test that if no short/long options are passed, only usage information is displayed (and displayed correctly ).
381+ * Test that if no short/long options are passed, only usage information is displayed (CS mode ).
382382 *
383383 * @param array<string> $cliArgs Command line arguments.
384384 * @param string $expectedRegex Regex to validate expected output.
@@ -387,15 +387,59 @@ public static function dataOptionFilteringSpacerHandling()
387387 *
388388 * @return void
389389 */
390- public function testDisplayUsage ($ cliArgs , $ expectedRegex )
390+ public function testDisplayUsageCS ($ cliArgs , $ expectedRegex )
391+ {
392+ if (PHP_CODESNIFFER_CBF === true ) {
393+ $ this ->markTestSkipped ('This test needs CS mode to run ' );
394+ }
395+
396+ $ expectedRegex = str_replace ('phpc(bf|s) ' , 'phpcs ' , $ expectedRegex );
397+ $ this ->verifyDisplayUsage ($ cliArgs , $ expectedRegex );
398+
399+ }//end testDisplayUsageCS()
400+
401+
402+ /**
403+ * Test that if no short/long options are passed, only usage information is displayed (CBF mode).
404+ *
405+ * @param array<string> $cliArgs Command line arguments.
406+ * @param string $expectedRegex Regex to validate expected output.
407+ *
408+ * @dataProvider dataDisplayUsage
409+ * @group CBF
410+ *
411+ * @return void
412+ */
413+ public function testDisplayUsageCBF ($ cliArgs , $ expectedRegex )
414+ {
415+ if (PHP_CODESNIFFER_CBF === false ) {
416+ $ this ->markTestSkipped ('This test needs CBF mode to run ' );
417+ }
418+
419+ $ expectedRegex = str_replace ('phpc(bf|s) ' , 'phpcbf ' , $ expectedRegex );
420+ $ this ->verifyDisplayUsage ($ cliArgs , $ expectedRegex );
421+
422+ }//end testDisplayUsageCBF()
423+
424+
425+ /**
426+ * Helper method to test that if no short/long options are passed, only usage information is displayed
427+ * (and displayed correctly).
428+ *
429+ * @param array<string> $cliArgs Command line arguments.
430+ * @param string $expectedRegex Regex to validate expected output.
431+ *
432+ * @return void
433+ */
434+ private function verifyDisplayUsage ($ cliArgs , $ expectedRegex )
391435 {
392436 $ help = new Help (new ConfigDouble ($ cliArgs ), []);
393437
394438 $ this ->expectOutputRegex ($ expectedRegex );
395439
396440 $ help ->display ();
397441
398- }//end testDisplayUsage ()
442+ }//end verifyDisplayUsage ()
399443
400444
401445 /**
0 commit comments