Skip to content

Tests: Assert unsupported requests for edit site export controller - #14115

Closed
shail-mehta wants to merge 3 commits into
WordPress:trunkfrom
shail-mehta:tests/66073-edit-site-export-negative-assertions
Closed

shail-mehta wants to merge 3 commits into
WordPress:trunkfrom
shail-mehta:tests/66073-edit-site-export-negative-assertions

Conversation

@shail-mehta

@shail-mehta shail-mehta commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Part of: #66073

What

Replaces empty @doesNotPerformAssertions get/create/update/delete stubs in Tests_REST_WpRestEditSiteExportController with real negative assertions.

Each unsupported request asserts rest_no_route with status 404, using an authenticated administrator.

Updated file: tests/phpunit/tests/rest-api/wpRestEditSiteExportController.php

Why

The edit site export controller only registers GET /wp-block-editor/v1/export. Empty abstract-method stubs hide whether unsupported operations are actually rejected, and the annotation count keeps growing.

This continues the agreed approach from [64004] / [64075] / [64076] on another conventional read-only controller, before any broader WP_Test_REST_Controller_Testcase change.

How

  • GET /wp-block-editor/v1/export/example → rest_no_route / 404 (no item route)
  • POST /wp-block-editor/v1/export → rest_no_route / 404 (route is GET-only)
  • POST / PUT / PATCH /wp-block-editor/v1/export → rest_no_route / 404 (asserts OPTIONS 200 first so the path is proven valid)
  • DELETE /wp-block-editor/v1/export → rest_no_route / 404 (asserts OPTIONS 200 first)
  • Uses OPTIONS instead of GET to prove the route: a successful GET triggers the ZIP export and exits the request
  • Left test_get_items() annotated (export GET is not a collection list operation)
  • Left prepare_item() / get_item_schema() unchanged (held for further discussion)
  • Did not change the abstract base class yet

Testing instructions

  1. Start the local WordPress develop environment.
  2. Run: npm run test:php -- --filter Tests_REST_WpRestEditSiteExportController

Use of AI tools

Cursor

@shail-mehta shail-mehta self-assigned this Oct 8, 2026
@shail-mehta
shail-mehta force-pushed the tests/66073-edit-site-export-negative-assertions branch from b011775 to 3355baf Compare October 8, 2026 17:36
@shail-mehta
shail-mehta marked this pull request as ready for review October 8, 2026 18:12
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props shailu25, lancewillett.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@lancewillett

Copy link
Copy Markdown
Member

Optional follow-up, not required before landing: alongside the OPTIONS status assertions, assert $this->assertSame( $route, $response->get_matched_route() );. rest_handle_options_request() returns a default 200 response even when no route matches, so status alone does not prove the export route exists. The existing route-registration test provides coverage, making this a small strengthening of these checks.

AI review · gpt-6

@lancewillett

Copy link
Copy Markdown
Member

PR #14115 landed in https://core.trac.wordpress.org/changeset/64275

wporg-sync pushed a commit that referenced this pull request Oct 10, 2026
Replace empty REST test stubs with assertions that item paths and write methods return `rest_no_route` for the site export controller.

Developed in: #14115

Props shailu25.
See #66073.


git-svn-id: https://develop.svn.wordpress.org/trunk@64275 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 10, 2026
Replace empty REST test stubs with assertions that item paths and write methods return `rest_no_route` for the site export controller.

Developed in: WordPress/wordpress-develop#14115

Props shailu25.
See #66073.

Built from https://develop.svn.wordpress.org/trunk@64275


git-svn-id: http://core.svn.wordpress.org/trunk@63425 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants