Skip to content

Tests: Assert unsupported requests for font collections controller - #14116

Open
shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:tests/66073-font-collections-negative-assertions
Open

shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:tests/66073-font-collections-negative-assertions

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

Part of: #66073

What

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

Each unsupported request asserts rest_no_route with status 404, using an authenticated administrator and a valid item fixture (mock-col-slug).

Updated file: tests/phpunit/tests/fonts/font-library/wpRestFontCollectionsController.php

Why

The font collections controller only registers readable collection and item routes. Empty abstract-method stubs hide whether unsupported write 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

  • POST /wp/v2/font-collections → rest_no_route / 404 (collection is GET-only)
  • POST / PUT / PATCH /wp/v2/font-collections/mock-col-slug → rest_no_route / 404 (item is GET-only; asserts GET 200 first so the path is proven valid)
  • DELETE /wp/v2/font-collections/mock-col-slug → rest_no_route / 404 (asserts GET 200 first)
  • Left prepare_item() 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_WpRestFontCollectionsController

Use of AI tools

Cursor

@shail-mehta
shail-mehta force-pushed the tests/66073-font-collections-negative-assertions branch from ba4edc1 to af0aea3 Compare October 8, 2026 17:45
@shail-mehta shail-mehta self-assigned this Oct 8, 2026
@shail-mehta
shail-mehta marked this pull request as ready for review October 8, 2026 18:11
@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.

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

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.

1 participant