From 38359ea934dd1f1d7222caa6c38dad4aef33e8df Mon Sep 17 00:00:00 2001 From: sayan goswami Date: Tue, 10 Sep 2024 18:16:07 +0530 Subject: [PATCH] Updated tests --- config/services.yml | 2 +- example/src/ExampleComplexity.php | 3 --- src/Enum/PhpcsStandardEnum.php | 14 ++++++++------ tests/Console/Command/Qa/QaFixerCommandTest.php | 10 ++++++---- .../Command/Qa/QaStaticAnalysisCommandTest.php | 12 +++++++----- 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/config/services.yml b/config/services.yml index dd25c210b..d8c884c6e 100644 --- a/config/services.yml +++ b/config/services.yml @@ -12,7 +12,7 @@ parameters: env(ORCA_PACKAGES_CONFIG): config/packages.yml ORCA_PACKAGES_CONFIG: "%env(ORCA_PACKAGES_CONFIG)%" env(ORCA_PACKAGES_CONFIG_ALTER): ~ - env(ORCA_PHPCS_STANDARD): "AcquiaDrupalTransitional" + env(ORCA_PHPCS_STANDARD): "AcquiaDrupalMinimal" env(ORCA_PHPUNIT_DEBUG_MODE_ENABLE): "false" env(ORCA_TELEMETRY_ENABLE): "false" env(ORCA_IS_ALLOWED_FAILURE): "%env(ORCA_IS_ALLOWED_FAILURE)%" diff --git a/example/src/ExampleComplexity.php b/example/src/ExampleComplexity.php index 0cb824071..2e52b9256 100644 --- a/example/src/ExampleComplexity.php +++ b/example/src/ExampleComplexity.php @@ -7,9 +7,6 @@ class ExampleComplexity { /** * Creates some cyclomatic complexity. - * - * @return int - * An arbitrary number. */ public function createComplexity(): int { $x = 0; diff --git a/src/Enum/PhpcsStandardEnum.php b/src/Enum/PhpcsStandardEnum.php index 7e36f4c09..dd52f4eef 100644 --- a/src/Enum/PhpcsStandardEnum.php +++ b/src/Enum/PhpcsStandardEnum.php @@ -14,13 +14,14 @@ */ final class PhpcsStandardEnum extends Enum { - public const ACQUIA_PHP = 'AcquiaPHP'; + public const ACQUIA_PHP_MINIMAL = 'AcquiaPHPMinimal '; + public const ACQUIA_PHP_STRICT = 'AcquiaPHPStrict '; public const ACQUIA_DRUPAL_STRICT = 'AcquiaDrupalStrict'; - public const ACQUIA_DRUPAL_TRANSITIONAL = 'AcquiaDrupalTransitional'; + public const ACQUIA_DRUPAL_MINIMAL = 'AcquiaDrupalMinimal'; - public const DEFAULT = self::ACQUIA_DRUPAL_TRANSITIONAL; + public const DEFAULT = self::ACQUIA_DRUPAL_MINIMAL; /** * Provides help text for commands that accept PHPCS standard input. @@ -30,9 +31,10 @@ final class PhpcsStandardEnum extends Enum { */ public static function commandHelp(): array { return [ - sprintf('- %s: Contains sniffs applicable to all PHP projects', self::ACQUIA_PHP), - sprintf('- %s: Recommended for new Drupal projects and teams familiar with Drupal coding standards', self::ACQUIA_DRUPAL_STRICT), - sprintf('- %s: A relaxed standard for legacy Drupal codebases or teams new to Drupal coding standards', self::ACQUIA_DRUPAL_TRANSITIONAL), + sprintf('- %s: Based on PSR-12 and is intended for use on all public non-Drupal projects', self::ACQUIA_PHP_MINIMAL), + sprintf('- %s: Based on AcquiaDrupal and adds the more opinionated DrupalPractice standard. It is intended for use on all internal Drupal projects', self::ACQUIA_DRUPAL_STRICT), + sprintf('- %s: Based on AcquiaPHP and adds additional, more opinionated standards. It is intended for use on all internal, non-Drupal projects', self::ACQUIA_PHP_STRICT), + sprintf('- %s: Based on the Drupal coding standard and is intended for use on all public Drupal projects', self::ACQUIA_DRUPAL_MINIMAL), ]; } diff --git a/tests/Console/Command/Qa/QaFixerCommandTest.php b/tests/Console/Command/Qa/QaFixerCommandTest.php index ff1780a91..168dbdd2a 100644 --- a/tests/Console/Command/Qa/QaFixerCommandTest.php +++ b/tests/Console/Command/Qa/QaFixerCommandTest.php @@ -153,8 +153,9 @@ public function testPhpcsStandardOption($args, $standard): void { public static function providerPhpcsStandardOption(): array { return [ [[], PhpcsStandardEnum::DEFAULT], - [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_PHP], PhpcsStandardEnum::ACQUIA_PHP], - [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_DRUPAL_TRANSITIONAL], PhpcsStandardEnum::ACQUIA_DRUPAL_TRANSITIONAL], + [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_PHP_MINIMAL], PhpcsStandardEnum::ACQUIA_PHP_MINIMAL], + [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_PHP_STRICT], PhpcsStandardEnum::ACQUIA_PHP_STRICT], + [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_DRUPAL_MINIMAL], PhpcsStandardEnum::ACQUIA_DRUPAL_MINIMAL], [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_DRUPAL_STRICT], PhpcsStandardEnum::ACQUIA_DRUPAL_STRICT], ]; } @@ -195,8 +196,9 @@ public function testPhpcsStandardEnvVar($standard): void { public static function providerPhpcsStandardEnvVar(): array { return [ - [PhpcsStandardEnum::ACQUIA_PHP], - [PhpcsStandardEnum::ACQUIA_DRUPAL_TRANSITIONAL], + [PhpcsStandardEnum::ACQUIA_PHP_STRICT], + [PhpcsStandardEnum::ACQUIA_PHP_MINIMAL], + [PhpcsStandardEnum::ACQUIA_DRUPAL_MINIMAL], [PhpcsStandardEnum::ACQUIA_DRUPAL_STRICT], ]; } diff --git a/tests/Console/Command/Qa/QaStaticAnalysisCommandTest.php b/tests/Console/Command/Qa/QaStaticAnalysisCommandTest.php index 824c50f9d..054b2b814 100644 --- a/tests/Console/Command/Qa/QaStaticAnalysisCommandTest.php +++ b/tests/Console/Command/Qa/QaStaticAnalysisCommandTest.php @@ -136,7 +136,7 @@ public static function providerOptions(): array { ['composer', FALSE], ['coverage', FALSE], ['phpcs', FALSE], - ['phpcs-standard', 'AcquiaDrupalTransitional'], + ['phpcs-standard', 'AcquiaDrupalMinimal'], ['phplint', FALSE], ['phploc', FALSE], ['phpmd', FALSE], @@ -307,8 +307,9 @@ public function testPhpcsStandardOption(array $args, $standard): void { public static function providerPhpcsStandardOption(): array { return [ [[], PhpcsStandardEnum::DEFAULT], - [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_PHP], PhpcsStandardEnum::ACQUIA_PHP], - [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_DRUPAL_TRANSITIONAL], PhpcsStandardEnum::ACQUIA_DRUPAL_TRANSITIONAL], + [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_PHP_STRICT], PhpcsStandardEnum::ACQUIA_PHP_STRICT], + [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_PHP_MINIMAL], PhpcsStandardEnum::ACQUIA_PHP_MINIMAL], + [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_DRUPAL_MINIMAL], PhpcsStandardEnum::ACQUIA_DRUPAL_MINIMAL], [['--phpcs-standard' => PhpcsStandardEnum::ACQUIA_DRUPAL_STRICT], PhpcsStandardEnum::ACQUIA_DRUPAL_STRICT], ]; } @@ -344,8 +345,9 @@ public function testPhpcsStandardEnvVar($standard): void { public static function providerPhpcsStandardEnvVar(): array { return [ - [PhpcsStandardEnum::ACQUIA_PHP], - [PhpcsStandardEnum::ACQUIA_DRUPAL_TRANSITIONAL], + [PhpcsStandardEnum::ACQUIA_PHP_STRICT], + [PhpcsStandardEnum::ACQUIA_PHP_MINIMAL], + [PhpcsStandardEnum::ACQUIA_DRUPAL_MINIMAL], [PhpcsStandardEnum::ACQUIA_DRUPAL_STRICT], ]; }