test(cli): add integration coverage for wp liveblog fix-archive#934
Open
faisalahammad wants to merge 1 commit into
Open
test(cli): add integration coverage for wp liveblog fix-archive#934faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
- add minimal WP_CLI stub for integration tests (log, success, colorize, add_command) - add WpCliFixArchiveTest covering dry-run, actual repair, no liveblogs found, and no edited entries fix-archive had zero automated test coverage. Issue Automattic#789 also asked to drop readme_for_github (already removed in 5becaad) and to refactor fix-archive with DI and a service class. That refactor already exists on 2.x (commit e760e10) but develop keeps the legacy static class style, so it is not ported here. Checked whether the corruption fix-archive repairs (broken liveblog_replaces meta after editing an entry twice) is still reachable: the supported REST/AJAX edit flow closed that path via PR Automattic#297, but validate_entry_belongs_to_post() still does not reject an entry_id that is itself an already-replaced comment, so the corruption remains possible in principle. fix-archive stays as a repair tool rather than being deprecated. Refs Automattic#789
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.
Summary
fix-archive had zero automated test coverage. Adds it, in the existing legacy style.
Refs #789
Investigation on #789
The issue asked for two things: drop the obsolete
readme_for_githubcommand, and refactorfix-archiveinto a namespaced command + service class with DI and behat tests.readme_for_githubis already gone — removed on develop in5becaad(PR Restructure documentation around audience #872), the same change that droppedreadme.txtin favor of a WordPress.org-compatibleREADME.md. Nothing to do there.2.xbranch (commite760e10:FixArchiveCommand+ArchiveRepairServiceundersrc/php/, with DI and unit tests).developis still the flat, legacy static-class style, and per project convention 2.x patterns are backported by hand when needed, not ported wholesale. Not doing that here.fix-archiverepairs (brokenliveblog_replacescommentmeta + duplicated content after editing an entry twice) is still reachable. PR users can edit more than 1x now and reloaded page will show #297 already closed the supported REST/AJAX path by canonicalizingentry_idthroughreplacesbefore it reaches the client. Butvalidate_entry_belongs_to_post()still doesn't reject anentry_idthat is itself an already-replaced ghost comment, so the same corruption stays reachable in principle (stale cached page, direct API caller, future regression). Recommend keepingfix-archive, not deprecating it.So the only real gap left under this issue is missing test coverage, which this PR adds.
Changes
tests/Integration/wp-cli-stub.php (new)
Minimal
WP_CLI/WP_CLI_Commandstub (log,success,colorize,add_command), guarded byclass_exists(). Needed because the real WP-CLI runtime isn't loaded under PHPUnit, andclass-wpcom-liveblog-wp-cli.phpcallsWP_CLI::add_command()at file-load time plusWP_CLI::log()/::success()/::colorize()insidefix_archive().tests/Integration/WpCliFixArchiveTest.php (new)
Extends the same
Yoast\WPTestUtils\WPIntegration\TestCasebase asEntryQueryTest.php. Covers:--dryrun) does not modifyliveblog_replacesmetaliveblog_replacesvalueTesting
Test 1: PHPCS
composer csResult: clean on both new files
Test 2: Lint
composer lintResult: no syntax errors
Test 3: CodeRabbit
coderabbit review --agentResult: 0 findings
Test 4: composer test:integration
Couldn't get a clean local
wp-envrun to verify this locally — repeated transient network failures during the WordPress core git clone / Alpine package install in the wp-env Docker build on this machine, unrelated to this change. Would appreciate a CI run or a maintainer re-run locally to confirm the four new test cases pass.