Skip to content

REST API: Add unit test coverage for WP_REST_Icon_Collections_Controller. See #66287. - #14195

Closed
noruzzamans wants to merge 2 commits into
WordPress:trunkfrom
noruzzamans:trac-66287-icon-collections-controller-tests
Closed

noruzzamans wants to merge 2 commits into
WordPress:trunkfrom
noruzzamans:trac-66287-icon-collections-controller-tests

Conversation

@noruzzamans

Copy link
Copy Markdown
Member

Backports comprehensive unit test coverage for WP_REST_Icon_Collections_Controller from Gutenberg PR WordPress/gutenberg#83168 (reviewed by @t-hamano).

Changes:

  • Tests that getting a specific collection requires edit_posts capability (test_get_item_requires_permissions).
  • Verifies response field filtering with _fields parameter on both collection and single item endpoints (test_get_items_fields_parameter, test_get_item_fields_parameter).
  • Tests that non-public collections (rest-visibility-private and built-in core-admin) are omitted from collection listing (test_get_items_omits_non_public_collections).
  • Tests that requesting non-public collections directly returns a 404 rest_icon_collection_not_found error via data provider (test_get_item_returns_404_for_non_public_collection).
  • Verifies collection query parameters default context to view (test_get_collection_params).

Trac ticket: https://core.trac.wordpress.org/ticket/66287


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@noruzzamans
noruzzamans marked this pull request as ready for review October 11, 2026 16:21
@github-actions

github-actions Bot commented Oct 11, 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 noruzzaman, wildworks, rejaulalomkhan.

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

@noruzzamans

Copy link
Copy Markdown
Member Author

Hi @t-hamano,

Thank you for the review!

In ff96a4e, I have updated test_get_item_schema() to align with Gutenberg:

  • Added schema title and type assertions (assertSame( 'icon-collection', $schema['title'] ) and assertSame( 'object', $schema['type'] )).
  • Added readonly flag assertions on all properties (slug, label, description).
  • Retained the OPTIONS /wp/v2/icon-collections request dispatch and assertCount( 3, $properties ).

WordPress Coding Standards (phpcs --standard=WordPress-Core) and PHP syntax checks pass 100% cleanly.

@rejaulalomkhan

Copy link
Copy Markdown
Member

Test report

Tested ff96a4e locally against trunk:

  • tests/phpunit/tests/icons/wpRestIconCollectionsController.php: 22 tests pass on single site and multisite (PHP 8.3), and with --order-by=reverse.
  • The whole icons group (148 tests) passes.
  • PHP 8.5: the test file passes, no deprecations.
  • PHPCS: no issues.

I also checked that the new tests catch regressions: making get_item_permissions_check() return true makes test_get_item_requires_permissions fail as expected. core-admin is a built-in collection in icon-library-manifest.php, so the data provider case covers real core data.

LGTM from a testing perspective.

AI assistance: Claude Code (Claude Opus 5.5) was used to run the checks above; I reviewed the results.

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

wporg-sync pushed a commit that referenced this pull request Oct 12, 2026
Adds tests for permission checks, `_fields` filtering, the schema, and collection parameters, and verifies that the built-in non-public `core-admin` collection is not exposed.

Developed in: #14195

Props noruzzaman, rejaulalomkhan, wildworks.
Fixes #66287.

git-svn-id: https://develop.svn.wordpress.org/trunk@64310 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 64310
GitHub commit: 380cab3

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Oct 12, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 12, 2026
Adds tests for permission checks, `_fields` filtering, the schema, and collection parameters, and verifies that the built-in non-public `core-admin` collection is not exposed.

Developed in: WordPress/wordpress-develop#14195

Props noruzzaman, rejaulalomkhan, wildworks.
Fixes #66287.
Built from https://develop.svn.wordpress.org/trunk@64310


git-svn-id: http://core.svn.wordpress.org/trunk@63460 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.

3 participants