Skip to content

Made the installer tests fail on PHPUnit notices and replaced mocks without expectations with stubs. - #3322

Merged
AlexSkrypnyk merged 2 commits into
mainfrom
feature/installer-notices
Nov 14, 2026
Merged

AlexSkrypnyk merged 2 commits into
mainfrom
feature/installer-notices

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Summary

The installer's phpunit.xml now fails the run on PHP notices and deprecations, and on PHPUnit's own warnings, notices and deprecations (failOnNotice, failOnDeprecation, failOnPhpunitWarning, failOnPhpunitNotice, failOnPhpunitDeprecation), and prints PHPUnit notice details with displayDetailsOnPhpunitNotices. Running composer test is clean again: OK (1676 tests, 5876 assertions).

The suite was printing N markers and ending with OK, but there were issues! ... PHPUnit Notices: 108 while still exiting 0, so neither local runs nor CI flagged it. The config only set failOnRisky and failOnWarning, and it never asked PHPUnit to show notice details, so the summary line was all anyone saw. Every one of the 108 notices was PHPUnit 12 reporting No expectations were configured for the mock object, which fires whenever a test calls createMock() and then only configures return values.

After merge, a new mock without expectations, a with() on a stub, or a source-triggered notice or deprecation turns the installer test job red instead of passing quietly. Production code under src/ doesn't change, and neither do .vortex/tests/phpunit.xml or the template's root PHPUnit config. failOnSkipped, failOnIncomplete and failOnEmptyTestSuite stay off, so skipped tests such as the TEST_CIRCLECI_TOKEN-gated ones still pass.

Before / After

BEFORE
  createMock() + method()->willReturn()   (no expects)
        │
        ▼
  PHPUnit 12: "No expectations were configured for the mock object"
        │
        ▼
  phpunit.xml: no failOnPhpunitNotice, no details
        │
        ▼
  "OK, but there were issues! PHPUnit Notices: 108"  ──►  exit 0 (CI green)

AFTER
  createStub() for doubles that only return values
  createMock() + expects() for doubles that assert calls
        │
        ▼
  phpunit.xml: failOn{Notice,Deprecation,PhpunitWarning,PhpunitNotice,PhpunitDeprecation}
               displayDetailsOnPhpunitNotices
        │
        ▼
  "OK (1676 tests, 5876 assertions)"  ──►  exit 0
  any new notice/deprecation          ──►  exit 1 with details

Changes

PHPUnit configuration

  • .vortex/installer/phpunit.xml adds the 5 failOn* attributes and displayDetailsOnPhpunitNotices. The existing <source restrictNotices="true" restrictWarnings="true" ignoreIndirectDeprecations="true"> still scopes PHP notices and deprecations to code under src/, so notices raised inside vendor packages don't fail the run.

Doubles that only return values are now stubs

  • DownloaderTest, RepositoryDownloaderTest, AbstractRunnerTest, OptionsResolverTest, FileManagerTest and InstallerPresenterTest use createStub() wherever the double never receives an expects(). Doubles that do assert calls (the archiver and file-downloader mocks with expects($this->once()), and the HTTP client in the GITHUB_TOKEN test with expects($this->exactly(2))) stay createMock().
  • In RepositoryDownloaderTest, the createMockHttpClient() and createMockFileDownloader() helpers become stubHttpClient() and stubFileDownloader(), matching the existing stubStatusClient() / stubRefClient() / stubThrowingClient() helpers. stubFileDownloader() returns Downloader instead of MockObject.
  • BuildCommandTest, CheckRequirementsCommandTest, InstallCommandTest and InstallExcludedPathsTest use stubs for the ExecutableFinder, ProcessRunner, FileLoggerInterface and RepositoryDownloader doubles. The self-returning run() callbacks now declare ProcessRunner as their return type instead of MockObject, and the unused MockObject imports are gone.

Argument checks that were never enforced

  • 5 tests in InstallerPresenterTest (testFooterBuildSucceeded, testFooterBuildSucceededWithHandlerOutput, testFooterBuildSkipped, testFooterBuildFailed, testFooterBuildFailedWithHandlerOutput) called ->with(InstallerPresenter::BUILD_RESULT_*) on runPostBuild() without an expects(). Once those doubles became stubs, the stricter config flagged it as a PHPUnit deprecation: with() on a stub has no effect, and PHPUnit 13 removes it. They're now mocks with expects($this->once()), so the build-result argument is actually asserted.

Summary by CodeRabbit

  • Tests
    • Automated checks now fail on notices, deprecations, and PHPUnit warnings, and display more detail for notices.
    • Test coverage and assertions remain unchanged; test setup has been updated without changing the behaviors being tested. These changes affect validation during development and do not alter the installer’s user-facing functionality.

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

This PR tightens PHPUnit failure reporting and updates installer tests to use stubs instead of mocks in many places. It also adds explicit runPostBuild() call expectations in InstallerPresenterTest. The listed test scenarios and assertions otherwise stay the same.

Changes: Installer test updates

Layer / File(s) Summary
PHPUnit failure settings
.vortex/installer/phpunit.xml
PHPUnit now fails on notices, deprecations, PHPUnit warnings, PHPUnit notices, and PHPUnit deprecations. It also enables PHPUnit notice detail output.
Command test doubles
.vortex/installer/tests/Functional/Command/BuildCommandTest.php, .vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php, .vortex/installer/tests/Functional/Command/InstallCommandTest.php, .vortex/installer/tests/Functional/Command/InstallExcludedPathsTest.php
Functional command tests replace several mocks with stubs for runners, loggers, finders, and downloaders. Callback return types change from MockObject to ProcessRunner, and removed imports match that change.
Downloader test helper stubs
.vortex/installer/tests/Unit/Downloader/DownloaderTest.php, .vortex/installer/tests/Unit/Downloader/RepositoryDownloaderTest.php
Downloader tests switch HTTP clients, requests, responses, archivers, and file downloaders from mocks to stubs. Helper methods are renamed to stubHttpClient and stubFileDownloader, and their returned test doubles are updated to stubs.
Presenter and utility test updates
.vortex/installer/tests/Unit/Prompts/InstallerPresenterTest.php, .vortex/installer/tests/Unit/Runner/AbstractRunnerTest.php, .vortex/installer/tests/Unit/Utils/FileManagerTest.php, .vortex/installer/tests/Unit/Utils/OptionsResolverTest.php
InstallerPresenterTest now requires runPostBuild() exactly once in successful, skipped, and failed build-result paths. Other unit tests replace simple mocks with stubs without changing the existing assertions.

Estimated code review effort: 2 (Simple) | ~12 minutes

Merge Risk: Minimal · up to 5f6a2

This change tightens installer test strictness and replaces some mocks with stubs. It does not touch production code, so the risk of merging is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title matches the main change. The PR makes the installer PHPUnit run fail on notices, and it replaces expectation-free mocks with stubs in the installer tests. Both parts appear in the raw summar…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title matches the main change. The PR makes the installer PHPUnit run fail on notices, and it replaces expectation-free mocks with stubs in the installer tests. Both parts appear in the raw summary and the PR objectives. The title is long at 100 characters, but it is specific and accurate.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 922ce8f and 5f6a2c7.

Files selected for processing: 11

  • .vortex/installer/phpunit.xml
  • .vortex/installer/tests/Functional/Command/BuildCommandTest.php
  • .vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php
  • .vortex/installer/tests/Functional/Command/InstallCommandTest.php
  • .vortex/installer/tests/Functional/Command/InstallExcludedPathsTest.php
  • .vortex/installer/tests/Unit/Downloader/DownloaderTest.php
  • .vortex/installer/tests/Unit/Downloader/RepositoryDownloaderTest.php
  • .vortex/installer/tests/Unit/Prompts/InstallerPresenterTest.php
  • .vortex/installer/tests/Unit/Runner/AbstractRunnerTest.php
  • .vortex/installer/tests/Unit/Utils/FileManagerTest.php
  • .vortex/installer/tests/Unit/Utils/OptionsResolverTest.php

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

@github-actions

Copy link
Copy Markdown

📖 Documentation preview for this pull request has been deployed to Netlify:

https://6af83f32c4043f69d657e686--vortex-docs.netlify.app

This preview is rebuilt on every commit and is not the production documentation site.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

1 similar comment
@AlexSkrypnyk

Copy link
Copy Markdown
Member Author

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   100.00% (233/233)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.67%. Comparing base (922ce8f) to head (5f6a2c7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3322   +/-   ##
=======================================
  Coverage   92.67%   92.67%           
=======================================
  Files         114      114           
  Lines        5077     5077           
  Branches       49       49           
=======================================
  Hits         4705     4705           
  Misses        372      372           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   100.00% (233/233)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Nov 14, 2026
@AlexSkrypnyk
AlexSkrypnyk merged commit acda1cb into main Nov 14, 2026
48 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/installer-notices branch November 14, 2026 11:34
@github-project-automation github-project-automation Bot moved this from BACKLOG to Release queue in Vortex 1.x Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs review Pull request needs a review from assigned developers

Projects

Status: Release queue

Development

Successfully merging this pull request may close these issues.

1 participant