Repository navigation
Made the installer tests fail on PHPUnit notices and replaced mocks without expectations with stubs. - #3322
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
📖 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. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
|
Code coverage (threshold: 90%) Per-class coverage |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
Code coverage (threshold: 90%) Per-class coverage |
Summary
The installer's
phpunit.xmlnow 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 withdisplayDetailsOnPhpunitNotices. Runningcomposer testis clean again:OK (1676 tests, 5876 assertions).The suite was printing
Nmarkers and ending withOK, but there were issues! ... PHPUnit Notices: 108while still exiting 0, so neither local runs nor CI flagged it. The config only setfailOnRiskyandfailOnWarning, 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 reportingNo expectations were configured for the mock object, which fires whenever a test callscreateMock()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 undersrc/doesn't change, and neither do.vortex/tests/phpunit.xmlor the template's root PHPUnit config.failOnSkipped,failOnIncompleteandfailOnEmptyTestSuitestay off, so skipped tests such as theTEST_CIRCLECI_TOKEN-gated ones still pass.Before / After
Changes
PHPUnit configuration
.vortex/installer/phpunit.xmladds the 5failOn*attributes anddisplayDetailsOnPhpunitNotices. The existing<source restrictNotices="true" restrictWarnings="true" ignoreIndirectDeprecations="true">still scopes PHP notices and deprecations to code undersrc/, so notices raised inside vendor packages don't fail the run.Doubles that only return values are now stubs
DownloaderTest,RepositoryDownloaderTest,AbstractRunnerTest,OptionsResolverTest,FileManagerTestandInstallerPresenterTestusecreateStub()wherever the double never receives anexpects(). Doubles that do assert calls (the archiver and file-downloader mocks withexpects($this->once()), and the HTTP client in theGITHUB_TOKENtest withexpects($this->exactly(2))) staycreateMock().RepositoryDownloaderTest, thecreateMockHttpClient()andcreateMockFileDownloader()helpers becomestubHttpClient()andstubFileDownloader(), matching the existingstubStatusClient()/stubRefClient()/stubThrowingClient()helpers.stubFileDownloader()returnsDownloaderinstead ofMockObject.BuildCommandTest,CheckRequirementsCommandTest,InstallCommandTestandInstallExcludedPathsTestuse stubs for theExecutableFinder,ProcessRunner,FileLoggerInterfaceandRepositoryDownloaderdoubles. The self-returningrun()callbacks now declareProcessRunneras their return type instead ofMockObject, and the unusedMockObjectimports are gone.Argument checks that were never enforced
InstallerPresenterTest(testFooterBuildSucceeded,testFooterBuildSucceededWithHandlerOutput,testFooterBuildSkipped,testFooterBuildFailed,testFooterBuildFailedWithHandlerOutput) called->with(InstallerPresenter::BUILD_RESULT_*)onrunPostBuild()without anexpects(). 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 withexpects($this->once()), so the build-result argument is actually asserted.Summary by CodeRabbit