From 358e4e4d23a8f05ca92cdab8c6ad0efdb6c7a198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Sun, 24 May 2026 14:50:09 +0200 Subject: [PATCH 1/6] Enhance report generation with new CI formats and refactor Markdown handling - Added support for new CI report formats: Checkstyle, JUnit, SARIF, GitLab Code Quality, and GitHub Actions. - Improved HTML and Markdown report generation with a single table configuration option. - Refactored MarkdownReport for better file handling and class section management, enhancing code readability and maintainability. - Updated tests to validate new report formats and configurations. --- .../workflows/cognitive-code-analysis.yaml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/cognitive-code-analysis.yaml diff --git a/.github/workflows/cognitive-code-analysis.yaml b/.github/workflows/cognitive-code-analysis.yaml new file mode 100644 index 0000000..9359dfd --- /dev/null +++ b/.github/workflows/cognitive-code-analysis.yaml @@ -0,0 +1,29 @@ +name: Cognitive Code Analysis + +on: + pull_request: + paths: + - '**/*.php' + +permissions: + pull-requests: write + contents: read + +jobs: + analyse: + name: Cognitive Code Analysis + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: Phauthentic/cognitive-code-analysis-github-action@v1 + with: + install-mode: phar + config: config.yml + post-comment: true + upload-artifact: true + emit-annotations: true + upload-sarif: false + fail-on-threshold: false From b63d5d2124522843bd14093896db109a9026e5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Sun, 24 May 2026 14:56:46 +0200 Subject: [PATCH 2/6] Update output files to include configuration and cache status - Added configuration file paths and cache status to various output files for improved clarity and debugging. - Updated output formats for all relevant test cases to reflect the new configuration and cache information. --- tests/Unit/Command/OutputWithAllMetrics.txt | 3 +++ tests/Unit/Command/OutputWithCyclomaticOnly.txt | 3 +++ tests/Unit/Command/OutputWithHalsteadOnly.txt | 3 +++ tests/Unit/Command/OutputWithMinimalConfig.txt | 3 +++ tests/Unit/Command/OutputWithSingleTable.txt | 3 +++ tests/Unit/Command/OutputWithThreshold.txt | 3 +++ tests/Unit/Command/OutputWithoutDetailedMetrics.txt | 3 +++ tests/Unit/Command/OutputWithoutOptions.txt | 3 +++ 8 files changed, 24 insertions(+) diff --git a/tests/Unit/Command/OutputWithAllMetrics.txt b/tests/Unit/Command/OutputWithAllMetrics.txt index 7f0deb0..c727036 100644 --- a/tests/Unit/Command/OutputWithAllMetrics.txt +++ b/tests/Unit/Command/OutputWithAllMetrics.txt @@ -1,3 +1,6 @@ +Config: ./tests/Unit/Command/../../../tests/Fixtures/all-metrics-config.yml +Cache: enabled + Class: \ClassOne File: tests/TestCode/FileWithTwoClasses.php ┌─────────────┬───────┬───────────┬─────────┬───────────┬──────────┬───────┬────────────┬───────┬────────────┬──────────┬────────────┬──────────┬────────────┐ diff --git a/tests/Unit/Command/OutputWithCyclomaticOnly.txt b/tests/Unit/Command/OutputWithCyclomaticOnly.txt index 8876118..101928b 100644 --- a/tests/Unit/Command/OutputWithCyclomaticOnly.txt +++ b/tests/Unit/Command/OutputWithCyclomaticOnly.txt @@ -1,3 +1,6 @@ +Config: ./tests/Unit/Command/../../../tests/Fixtures/cyclomatic-only-config.yml +Cache: enabled + Class: \ClassOne File: tests/TestCode/FileWithTwoClasses.php ┌─────────────┬───────┬───────────┬─────────┬───────────┬──────────┬───────┬────────────┬───────┬────────────┬────────────┐ diff --git a/tests/Unit/Command/OutputWithHalsteadOnly.txt b/tests/Unit/Command/OutputWithHalsteadOnly.txt index dca2f2f..722556f 100644 --- a/tests/Unit/Command/OutputWithHalsteadOnly.txt +++ b/tests/Unit/Command/OutputWithHalsteadOnly.txt @@ -1,3 +1,6 @@ +Config: ./tests/Unit/Command/../../../tests/Fixtures/halstead-only-config.yml +Cache: enabled + Class: \ClassOne File: tests/TestCode/FileWithTwoClasses.php ┌─────────────┬───────┬───────────┬─────────┬───────────┬──────────┬───────┬────────────┬───────┬────────────┬──────────┬────────────┬──────────┐ diff --git a/tests/Unit/Command/OutputWithMinimalConfig.txt b/tests/Unit/Command/OutputWithMinimalConfig.txt index 06bc1ea..c0c9eb3 100644 --- a/tests/Unit/Command/OutputWithMinimalConfig.txt +++ b/tests/Unit/Command/OutputWithMinimalConfig.txt @@ -1,3 +1,6 @@ +Config: ./tests/Unit/Command/../../../tests/Fixtures/minimal-config.yml +Cache: enabled + Class: \ClassOne File: tests/TestCode/FileWithTwoClasses.php ┌─────────────┬────────────┐ diff --git a/tests/Unit/Command/OutputWithSingleTable.txt b/tests/Unit/Command/OutputWithSingleTable.txt index 58a52e0..a3af12c 100644 --- a/tests/Unit/Command/OutputWithSingleTable.txt +++ b/tests/Unit/Command/OutputWithSingleTable.txt @@ -1,3 +1,6 @@ +Config: ./tests/Unit/Command/../../../tests/Fixtures/single-table-config.yml +Cache: enabled + All Methods (23 total) ┌──────────────────────────────────────────┬───────────────────────────────────────────┬──────────────┬───────────┬─────────┬─────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬───────────┬────────────┬────────────┬─────────────────┐ │ Class │ Method Name │ Lines │ Arguments │ Returns │ Variables │ Property │ If │ If Nesting │ Else │ Cognitive │ Halstead │ Halstead │ Halstead │ Cyclomatic │ diff --git a/tests/Unit/Command/OutputWithThreshold.txt b/tests/Unit/Command/OutputWithThreshold.txt index f59730f..31fb2cc 100644 --- a/tests/Unit/Command/OutputWithThreshold.txt +++ b/tests/Unit/Command/OutputWithThreshold.txt @@ -1,3 +1,6 @@ +Config: ./tests/Unit/Command/../../../tests/Fixtures/threshold-config.yml +Cache: enabled + Class: \Doctrine\ORM\Tools\Pagination\Paginator File: tests/TestCode/Paginator.php ┌───────────────────────────────────────────┬────────┬───────────┬─────────┬───────────┬──────────┬───────┬────────────┬───────────┬────────────┬──────────┬────────────┬──────────┬────────────┐ diff --git a/tests/Unit/Command/OutputWithoutDetailedMetrics.txt b/tests/Unit/Command/OutputWithoutDetailedMetrics.txt index 2e5fa4d..229f49d 100644 --- a/tests/Unit/Command/OutputWithoutDetailedMetrics.txt +++ b/tests/Unit/Command/OutputWithoutDetailedMetrics.txt @@ -1,3 +1,6 @@ +Config: ./tests/Unit/Command/../../../tests/Fixtures/no-detailed-metrics-config.yml +Cache: enabled + Class: \ClassOne File: tests/TestCode/FileWithTwoClasses.php ┌─────────────┬────────────┬──────────┬────────────┬──────────┬────────────┐ diff --git a/tests/Unit/Command/OutputWithoutOptions.txt b/tests/Unit/Command/OutputWithoutOptions.txt index 82d0e4d..e8d1ffb 100644 --- a/tests/Unit/Command/OutputWithoutOptions.txt +++ b/tests/Unit/Command/OutputWithoutOptions.txt @@ -1,3 +1,6 @@ +Config: ./tests/Unit/Command/minimal-config.yml +Cache: disabled + Class: \ClassOne File: tests/TestCode/FileWithTwoClasses.php ┌─────────────┬───────┬───────────┬─────────┬───────────┬──────────┬───────┬────────────┬───────┬────────────┐ From 99f3bf0205ed5d9d7a0d137503de1763a9a416d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Sun, 24 May 2026 14:59:56 +0200 Subject: [PATCH 3/6] Refactor configuration management and update file references - Replaced instances of `config.yml` with `phpcca.yaml` across the codebase to standardize configuration file usage. - Introduced a new `phpcca.yaml` file containing cognitive metrics configuration settings. - Updated README.md to reflect the new copyright format. - Adjusted GitHub Actions workflow to utilize the new configuration file. --- .github/workflows/cognitive-code-analysis.yaml | 2 +- box.json.dist | 2 +- config.yml => phpcca.yaml | 0 readme.md | 2 +- src/Application.php | 2 +- src/Config/ConfigService.php | 4 ++-- tests/Unit/Config/ConfigInitializerTest.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) rename config.yml => phpcca.yaml (100%) diff --git a/.github/workflows/cognitive-code-analysis.yaml b/.github/workflows/cognitive-code-analysis.yaml index 9359dfd..8df3ac5 100644 --- a/.github/workflows/cognitive-code-analysis.yaml +++ b/.github/workflows/cognitive-code-analysis.yaml @@ -21,7 +21,7 @@ jobs: - uses: Phauthentic/cognitive-code-analysis-github-action@v1 with: install-mode: phar - config: config.yml + config: phpcca.yaml post-comment: true upload-artifact: true emit-annotations: true diff --git a/box.json.dist b/box.json.dist index bfd0e5b..547ccf5 100644 --- a/box.json.dist +++ b/box.json.dist @@ -9,7 +9,7 @@ "KevinGH\\Box\\Compactor\\PhpScoper" ], "files": [ - "config.yml", + "phpcca.yaml", "composer.json", "readme.md", "LICENSE" diff --git a/config.yml b/phpcca.yaml similarity index 100% rename from config.yml rename to phpcca.yaml diff --git a/readme.md b/readme.md index 0c67f50..9e1f823 100644 --- a/readme.md +++ b/readme.md @@ -163,6 +163,6 @@ Especially the AST-parser used under the hood to analyse the code might have iss ## License ⚖️ -Copyright Florian Krämer +Copyright [Florian Krämer](https://florian-kraemer.net/) Licensed under the [GPL3 license](LICENSE). diff --git a/src/Application.php b/src/Application.php index eb15c85..3dcfed7 100644 --- a/src/Application.php +++ b/src/Application.php @@ -192,7 +192,7 @@ private function registerUtilityServices(): void ->setArguments([ new Reference(Processor::class), new Reference(ConfigLoader::class), - __DIR__ . '/../config.yml', + __DIR__ . '/../phpcca.yaml', ]) ->setPublic(true); diff --git a/src/Config/ConfigService.php b/src/Config/ConfigService.php index 187a773..f645b88 100644 --- a/src/Config/ConfigService.php +++ b/src/Config/ConfigService.php @@ -27,7 +27,7 @@ public function __construct( private function loadDefaultConfig(): void { $config = $this->processor->processConfiguration($this->configuration, [ - Yaml::parseFile(__DIR__ . '/../../config.yml'), + Yaml::parseFile(__DIR__ . '/../../phpcca.yaml'), ]); $this->config = (new ConfigFactory())->fromArray($config); @@ -38,7 +38,7 @@ private function loadDefaultConfig(): void */ public function loadConfig(string $configFilePath): void { - $defaultConfig = Yaml::parseFile(__DIR__ . '/../../config.yml'); + $defaultConfig = Yaml::parseFile(__DIR__ . '/../../phpcca.yaml'); $providedConfig = Yaml::parseFile($configFilePath); $config = $this->processor->processConfiguration($this->configuration, [ diff --git a/tests/Unit/Config/ConfigInitializerTest.php b/tests/Unit/Config/ConfigInitializerTest.php index efdad8f..eff5d8f 100644 --- a/tests/Unit/Config/ConfigInitializerTest.php +++ b/tests/Unit/Config/ConfigInitializerTest.php @@ -73,7 +73,7 @@ private function createInitializer(): ConfigInitializer return new ConfigInitializer( new Processor(), new ConfigLoader(), - __DIR__ . '/../../../config.yml', + __DIR__ . '/../../../phpcca.yaml', ); } From 1b07bdac2dccfbda08d3b74d5bfde662af25d118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Sun, 24 May 2026 15:02:44 +0200 Subject: [PATCH 4/6] Update configuration file references to phpcca.yaml - Changed all instances of cca.yaml to phpcca.yaml across documentation and codebase for consistency. - Updated README.md, CI-Integration.md, and Configuration.md to reflect the new configuration file name. - Modified InitCommand and related tests to create and reference phpcca.yaml instead of cca.yaml. --- docs/CI-Integration.md | 10 +++++----- docs/Configuration.md | 8 ++++---- readme.md | 6 +++--- src/Command/InitCommand.php | 2 +- src/Config/ConfigFileResolver.php | 2 +- tests/Unit/Command/InitCommandTest.php | 4 ++-- .../Command/Presentation/RuntimeStatusRendererTest.php | 4 ++-- tests/Unit/Config/ConfigInitializerTest.php | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/CI-Integration.md b/docs/CI-Integration.md index 49bb73f..275cabd 100644 --- a/docs/CI-Integration.md +++ b/docs/CI-Integration.md @@ -13,7 +13,7 @@ A typical CI integration follows these steps: 3. Run `bin/phpcca analyse` on those files only 4. Publish the report (Markdown comment, SARIF upload, or quality gate) -When `cca.yaml` exists in the project root, `analyse` loads it automatically. Use `--config=path/to/config.yaml` to override. +When `phpcca.yaml` exists in the project root, `analyse` loads it automatically. Use `--config=path/to/config.yaml` to override. ## Report formats for CI @@ -38,7 +38,7 @@ See [Baseline Analysis](./Baseline-Analysis.md) to compare metrics against a pre The workflow below runs on pull requests, analyses changed PHP files, posts a Markdown report as a PR comment, and uploads the report as an artifact. -Add `--config=cca.yaml` if your config file is not named `cca.yaml` or not in the working directory. +Add `--config=phpcca.yaml` if your config file is not named `phpcca.yaml` or not in the working directory. ```yaml name: Code Metrics @@ -142,7 +142,7 @@ Then upload `results.sarif` using the [GitHub Code Scanning upload action](https The job below runs on merge requests, analyses changed PHP files, posts a Markdown report as an MR note, and stores the report as an artifact. -Use `--config=cca.yaml` when your config file is not auto-discovered from the project root. +Use `--config=phpcca.yaml` when your config file is not auto-discovered from the project root. ```yaml Code-Metrics: @@ -166,7 +166,7 @@ Code-Metrics: CHANGED_FILES=$(find src/ -name "*.php" | tr '\n' ' ') fi if [ -n "$CHANGED_FILES" ]; then - bin/phpcca analyse $CHANGED_FILES --report-type=markdown --report-file=cca-report.md --config=cca.yaml + bin/phpcca analyse $CHANGED_FILES --report-type=markdown --report-file=cca-report.md --config=phpcca.yaml if [ -f "cca-report.md" ] && [ -s "cca-report.md" ]; then # Try with CI_JOB_TOKEN first, fallback to CI/CD variables if [ -n "$VALIDATOR" ]; then @@ -237,7 +237,7 @@ GitLab picks up the Code Quality report automatically when configured in your pi ## Related -- [Configuration](./Configuration.md) — project setup with `bin/phpcca init` and `cca.yaml` +- [Configuration](./Configuration.md) — project setup with `bin/phpcca init` and `phpcca.yaml` - [Baseline Analysis](./Baseline-Analysis.md) — track complexity changes over time - [Creating Custom Reporters](./Creating-Custom-Reporters.md) — extend report output for custom CI integrations - [Issue #29](https://github.com/Phauthentic/cognitive-code-analysis/issues/29) — original feature discussion for GitHub Actions and branch comparison diff --git a/docs/Configuration.md b/docs/Configuration.md index 5bffc01..a592032 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -2,15 +2,15 @@ ## Creating a configuration file -Run `init` to create a `cca.yaml` in your project: +Run `init` to create a `phpcca.yaml` in your project: ```bash bin/phpcca init bin/phpcca init --silent -bin/phpcca init --path=/path/to/cca.yaml +bin/phpcca init --path=/path/to/phpcca.yaml ``` -When `cca.yaml` exists in the working directory, `analyse` and `churn` pick it up automatically. You only need `--config` for a custom path or filename. +When `phpcca.yaml` exists in the working directory, `analyse` and `churn` pick it up automatically. You only need `--config` for a custom path or filename. ## Passing a configuration file @@ -20,7 +20,7 @@ You can specify another configuration file by passing it to the config options: bin/phpcca analyse --config= ``` -When both `cca.yaml` and `--config` are available, the explicit `--config` path takes precedence. +When both `phpcca.yaml` and `--config` are available, the explicit `--config` path takes precedence. ## Excluding Classes and Methods diff --git a/readme.md b/readme.md index 9e1f823..1a0c808 100644 --- a/readme.md +++ b/readme.md @@ -37,12 +37,12 @@ composer require --dev phauthentic/cognitive-code-analysis Create a project configuration file: ```bash -bin/phpcca init # interactive setup → creates cca.yaml in current directory +bin/phpcca init # interactive setup → creates phpcca.yaml in current directory bin/phpcca init --silent # non-interactive, all defaults -bin/phpcca init --path=/path/to/cca.yaml +bin/phpcca init --path=/path/to/phpcca.yaml ``` -When `cca.yaml` exists in the current working directory, `analyse` and `churn` load it automatically. Use `--config` to specify a different file. +When `phpcca.yaml` exists in the current working directory, `analyse` and `churn` load it automatically. Use `--config` to specify a different file. Cognitive Complexity Analysis diff --git a/src/Command/InitCommand.php b/src/Command/InitCommand.php index 53c1cb0..8e02537 100644 --- a/src/Command/InitCommand.php +++ b/src/Command/InitCommand.php @@ -16,7 +16,7 @@ #[AsCommand( name: 'init', - description: 'Create a default cca.yaml for cognitive code analysis.' + description: 'Create a default phpcca.yaml for cognitive code analysis.' )] class InitCommand extends Command { diff --git a/src/Config/ConfigFileResolver.php b/src/Config/ConfigFileResolver.php index 11ceb31..791c224 100644 --- a/src/Config/ConfigFileResolver.php +++ b/src/Config/ConfigFileResolver.php @@ -6,7 +6,7 @@ class ConfigFileResolver { - public const DEFAULT_FILENAME = 'cca.yaml'; + public const DEFAULT_FILENAME = 'phpcca.yaml'; public function resolve(?string $explicitConfigPath): ?string { diff --git a/tests/Unit/Command/InitCommandTest.php b/tests/Unit/Command/InitCommandTest.php index c93f93c..478acab 100644 --- a/tests/Unit/Command/InitCommandTest.php +++ b/tests/Unit/Command/InitCommandTest.php @@ -30,7 +30,7 @@ protected function tearDown(): void #[Test] public function silentModeCreatesConfigWithDefaultsAtGivenPath(): void { - $targetPath = $this->tempDir . '/cca.yaml'; + $targetPath = $this->tempDir . '/phpcca.yaml'; $tester = $this->createCommandTester(); $statusCode = $tester->execute([ @@ -61,7 +61,7 @@ public function silentModeUsesDefaultPathInWorkingDirectory(): void $statusCode = $tester->execute(['--silent' => true]); $this->assertSame(Command::SUCCESS, $statusCode); - $this->assertFileExists($this->tempDir . '/cca.yaml'); + $this->assertFileExists($this->tempDir . '/phpcca.yaml'); } finally { chdir($originalWorkingDirectory); } diff --git a/tests/Unit/Command/Presentation/RuntimeStatusRendererTest.php b/tests/Unit/Command/Presentation/RuntimeStatusRendererTest.php index 7bac75c..c9f195c 100644 --- a/tests/Unit/Command/Presentation/RuntimeStatusRendererTest.php +++ b/tests/Unit/Command/Presentation/RuntimeStatusRendererTest.php @@ -50,10 +50,10 @@ public function renderShowsConfigPathAndDisabledCache(): void $output = new BufferedOutput(); $renderer = new RuntimeStatusRenderer(); - $renderer->render($output, $tempDir . '/cca.yaml', $this->createConfig(cacheEnabled: false)); + $renderer->render($output, $tempDir . '/phpcca.yaml', $this->createConfig(cacheEnabled: false)); $this->assertSame( - "Config: ./cca.yaml\nCache: disabled\n\n", + "Config: ./phpcca.yaml\nCache: disabled\n\n", $output->fetch() ); diff --git a/tests/Unit/Config/ConfigInitializerTest.php b/tests/Unit/Config/ConfigInitializerTest.php index eff5d8f..95043a8 100644 --- a/tests/Unit/Config/ConfigInitializerTest.php +++ b/tests/Unit/Config/ConfigInitializerTest.php @@ -59,7 +59,7 @@ public function writeConfigFileCreatesFileAndParentDirectory(): void { $initializer = $this->createInitializer(); $config = $initializer->createDefaultConfig(); - $targetPath = $this->tempDir . '/nested/cca.yaml'; + $targetPath = $this->tempDir . '/nested/phpcca.yaml'; $initializer->writeConfigFile($targetPath, $config); From 85eb04d6b6c379ecfcedc3aeb4ac7f91361794b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Sun, 24 May 2026 15:04:24 +0200 Subject: [PATCH 5/6] Update cognitive metrics configuration in phpcca.yaml - Changed the setting for showOnlyMethodsExceedingThreshold from false to true to enhance cognitive metrics reporting. --- phpcca.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcca.yaml b/phpcca.yaml index bef1733..5ac88b6 100644 --- a/phpcca.yaml +++ b/phpcca.yaml @@ -2,7 +2,7 @@ cognitive: excludeFilePatterns: excludePatterns: scoreThreshold: 0.5 - showOnlyMethodsExceedingThreshold: false + showOnlyMethodsExceedingThreshold: true showHalsteadComplexity: false showCyclomaticComplexity: false showDetailedCognitiveMetrics: true From 520e1f6499cca383ff7b739ec9cae6e04fcd62f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Sun, 24 May 2026 15:08:16 +0200 Subject: [PATCH 6/6] Refactor CognitiveMetricsCommandCoverageTest to use a centralized test configuration method - Introduced a private method `withTestConfig` to streamline the execution of tests with a specified configuration file. - Updated all test cases in `CognitiveMetricsCommandCoverageTest` to utilize the new method for improved readability and maintainability. --- .../CognitiveMetricsCommandCoverageTest.php | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/tests/Unit/Command/CognitiveMetricsCommandCoverageTest.php b/tests/Unit/Command/CognitiveMetricsCommandCoverageTest.php index 8de9326..bbf3b30 100644 --- a/tests/Unit/Command/CognitiveMetricsCommandCoverageTest.php +++ b/tests/Unit/Command/CognitiveMetricsCommandCoverageTest.php @@ -17,6 +17,17 @@ */ class CognitiveMetricsCommandCoverageTest extends TestCase { + private const TEST_CONFIG = __DIR__ . '/minimal-config.yml'; + + /** + * @param array $input + * @return array + */ + private function withTestConfig(array $input): array + { + return ['--config' => self::TEST_CONFIG] + $input; + } + #[Test] #[DataProvider('coverageFormatProvider')] public function testAnalyseWithCoverageFormats(string $option, string $file, string $format): void @@ -25,10 +36,10 @@ public function testAnalyseWithCoverageFormats(string $option, string $file, str $command = $application->getContainer()->get(CognitiveMetricsCommand::class); $tester = new CommandTester($command); - $tester->execute([ + $tester->execute($this->withTestConfig([ 'path' => __DIR__ . '/../../TestCode/Paginator.php', $option => __DIR__ . '/../../Fixtures/Coverage/' . $file, - ]); + ])); $this->assertEquals( Command::SUCCESS, @@ -48,11 +59,11 @@ public function testAnalyseWithBothCoverageFormatsReturnsError(): void $command = $application->getContainer()->get(CognitiveMetricsCommand::class); $tester = new CommandTester($command); - $tester->execute([ + $tester->execute($this->withTestConfig([ 'path' => __DIR__ . '/../../TestCode/Paginator.php', '--coverage-clover' => __DIR__ . '/../../Fixtures/Coverage/testcode-clover.xml', '--coverage-cobertura' => __DIR__ . '/../../Fixtures/Coverage/testcode-cobertura.xml', - ]); + ])); $this->assertEquals( Command::FAILURE, @@ -71,10 +82,10 @@ public function testAnalyseWithNonExistentCoverageFile(): void $command = $application->getContainer()->get(CognitiveMetricsCommand::class); $tester = new CommandTester($command); - $tester->execute([ + $tester->execute($this->withTestConfig([ 'path' => __DIR__ . '/../../TestCode/Paginator.php', '--coverage-clover' => __DIR__ . '/../../Fixtures/Coverage/does-not-exist.xml', - ]); + ])); $this->assertEquals( Command::FAILURE, @@ -93,9 +104,9 @@ public function testAnalyseWithoutCoverageDoesNotShowCoverageColumn(): void $command = $application->getContainer()->get(CognitiveMetricsCommand::class); $tester = new CommandTester($command); - $tester->execute([ + $tester->execute($this->withTestConfig([ 'path' => __DIR__ . '/../../TestCode/Paginator.php', - ]); + ])); $this->assertEquals(Command::SUCCESS, $tester->getStatusCode()); $output = $tester->getDisplay(); @@ -119,10 +130,10 @@ public function testAnalyseShowsMethodLevelCoverage( $command = $application->getContainer()->get(CognitiveMetricsCommand::class); $tester = new CommandTester($command); - $tester->execute([ + $tester->execute($this->withTestConfig([ 'path' => __DIR__ . '/../../TestCode/Paginator.php', "--coverage-{$format}" => __DIR__ . '/../../Fixtures/Coverage/' . $file, - ]); + ])); $this->assertEquals(Command::SUCCESS, $tester->getStatusCode()); $output = $tester->getDisplay(); @@ -148,10 +159,10 @@ public function testAnalyseWithCoverageAndMultiplePaths(): void $command = $application->getContainer()->get(CognitiveMetricsCommand::class); $tester = new CommandTester($command); - $tester->execute([ + $tester->execute($this->withTestConfig([ 'path' => __DIR__ . '/../../TestCode/Paginator.php,' . __DIR__ . '/../../TestCode/FileWithTwoClasses.php', '--coverage-clover' => __DIR__ . '/../../Fixtures/Coverage/testcode-clover.xml', - ]); + ])); $this->assertEquals( Command::SUCCESS,