3
3
* Tests to verify that the "help" command functions as expected.
4
4
*
5
5
* @author Juliette Reinders Folmer <[email protected] >
6
- * @copyright 2024 Juliette Reinders Folmer. All rights reserved.
6
+ * @copyright 2024 PHPCSStandards and contributors
7
7
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
8
*/
9
9
@@ -386,7 +386,7 @@ public static function dataOptionFilteringSpacerHandling()
386
386
387
387
388
388
/**
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 ).
390
390
*
391
391
* @param array<string> $cliArgs Command line arguments.
392
392
* @param string $expectedRegex Regex to validate expected output.
@@ -395,15 +395,59 @@ public static function dataOptionFilteringSpacerHandling()
395
395
*
396
396
* @return void
397
397
*/
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 )
399
443
{
400
444
$ help = new Help (new ConfigDouble ($ cliArgs ), []);
401
445
402
446
$ this ->expectOutputRegex ($ expectedRegex );
403
447
404
448
$ help ->display ();
405
449
406
- }//end testDisplayUsage ()
450
+ }//end verifyDisplayUsage ()
407
451
408
452
409
453
/**
0 commit comments