Repository navigation
test: isolate WordPress hooks between feature tests - #330
Merged
Merged
Conversation
Tests\TestCase uses Pollora\Testing\IsolatesWordPressHooks, and a feature test guards it. Requires pollora/framework ^13.45.2. Refs Pollora/framework#741
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
New projects use
Pollora\Testing\IsolatesWordPressHooks(pollora/framework v13.45.2) intests/TestCase.php, so the WordPress hooks of one feature test no longer reach the next one. This is the skeleton side of Pollora/framework#741.composer.jsonrequirespollora/framework^13.45.2. The lock already pinned v13.45.2; only itscontent-hashchanges.tests/Feature/WordPressHookIsolationTest.phpships with every project. It is one test that builds its applications itself (tearDown()thensetUp()), so it does not depend on order or on other tests being selected. It checks that hooks added by the test (add_action()and theActionfacade) are gone in the next application, thatwp_footerruns in a later application, that the number of callbacks is the same in two successive applications, and that the views of a theme found inthemes/are registered in later applications.phpunit.xmlis unchanged and keepsAPP_ENV=testing, which the test also asserts.How to test it
Only the
Install (locked)andInstall (develop)jobs oftests.ymlruntests/Feature(ddev composer test, on an installed WordPress with thedefaulttheme). The install scenarios,assets,contentand the harness jobs do not run it.With and without the trait, on an installed WordPress, in both
Installjobs (lockedanddevelop) of https://github.com/Pollora/pollora/actions/runs/47373396266. That run was started by hand on a temporary branch, since deleted: this commit without theuse IsolatesWordPressHooks;line, plus a temporary file holding thewp_footerand callback-count cases separately, and a step printing the Pest output. Its two commits on top of this one: c4feb36b (trait removed) and 6ace2a12 (temporary cases and workflow step). The jobs are green because the failing commands were tolerated there; the results are in the log.Failed asserting that true is false(the probe hook is still there)wp_footercase aloneTarget [Pollora\Theme\Domain\Contracts\ThemeJsonResolverInterface] is not instantiable.1365 is identical to 1215Lock is currentis skipped on pull requests from a branch with this name, so it was started by hand on this branch: https://github.com/Pollora/pollora/actions/runs/47372445631What this does not prove
wp_footerand the callback count were shown failing on their own through the temporary copies only.themes/<active theme>/resources/views.wp_footeralso runs the callbacks of the project it ships to; only the stock skeleton and default theme are covered by CI.RefreshDatabase, parallel testing, multisite and third-party plugins are not covered.Checklist
main(this repository has nodevelopbranch)ddev composer testpasses: in CI, in bothInstalljobs of this pull request (not run locally)pint.json)CHANGELOG.mdupdated under[Unreleased]Also run locally:
.github/scripts/check-skeleton-content.sh,.github/scripts/tests/check-upstream.test.sh,.github/scripts/check-upstream.shandcomposer validate. The skeleton defines nocomposer qa:fastorcomposer qascript.