Make WordPress Core

#57841 closed task (blessed) (fixed)

Test tool and unit test improvements for 6.3

Reported by: hellofromtonya's profile hellofromTonya Owned by:
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Previously:

This ticket is for various fixes and improvements in PHPUnit tests that don't have a more specific ticket, as well as general improvements to the GitHub Actions workflows that run automated testing.

Change History (29)

This ticket was mentioned in PR #3745 on WordPress/wordpress-develop by @costdev.


16 months ago
#1

  • Keywords has-patch has-unit-tests added

This PR:

  • [x] Converts the class to extend WP_Theme_UnitTestCase.
  • [x] Adds a @covers annotation.
  • [x] Renames the test class to be compliant with standards.
  • [x] Moves an unrelated test, test_should_enqueue_stored_styles() to its own file.
  • [x] Implements a data provider for the tests to reduce code repetition.

Trac ticket:
https://core.trac.wordpress.org/ticket/57841
https://core.trac.wordpress.org/ticket/56793

This ticket was mentioned in PR #4244 on WordPress/wordpress-develop by @hellofromTonya.


16 months ago
#2

Adds a test class for wp_script_is() and moves existing tests into this class.

There is a test in WP_Dependencies_jQuery that covers wp_script_is(). The coverage is incomplete. This PR relocates that test to the new Tests_Dependencies_WpScriptIs test class.

Includes @covers for wp_script_is() which is a wrapper around WP_Scripts::query.

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

#3 @SergeyBiryukov
16 months ago

In 55562:

Tests: Use the data_ prefix for various data provider methods.

This aims to bring more consistency to the test suite, as the vast majority of data providers already use that prefix.

Includes moving some data providers next to the tests they are used in.

Follow-up to [55464].

See #57841.

#4 @SergeyBiryukov
16 months ago

In 55563:

Tests: Improve documentation and variable names in some formatting tests.

Includes documenting data provider values using hash notation in the tests for:

  • convert_smilies()
  • get_url_in_content()
  • links_add_target()
  • normalize_whitespace()

Follow-up to [26191], [26327], [26328], [26972], [55562].

See #57841.

#5 @hellofromTonya
16 months ago

In 55565:

Tests: Add test class for wp_script_is().

Changes:

  • Adds a test class for wp_script_is().
  • Moves WP_Dependencies_jQuery::test_wp_script_is_dep_enqueued() into this test class and splits it into 2 separate tests, happy and unhappy paths.
  • Adds WP_Scripts::query @covers, as wp_script_is() is helper function for it.
  • Relocates the global resetting from the test method to the clean_up_global_scope() method.

Follow-up to [52010], [29252].

Props hellofromTonya, antonvlasenko.
See #57841, #57958.

@hellofromTonya commented on PR #4244:


16 months ago
#6

Thank you @anton-vlasenko! Committed via https://core.trac.wordpress.org/changeset/55565.

This ticket was mentioned in PR #4252 on WordPress/wordpress-develop by @hellofromTonya.


16 months ago
#7

Tests: Add test class for wp_enqueue_stored_styles().

[54214] added tests and global reset for wp_enqueue_stored_styles() into the Tests_Theme_wpGetGlobalStylesheet. This changeset adds a new test case for the function and relocates its tests to it.

Follow-up to [54214].

Props costdev.
See #57841.

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

#8 @hellofromTonya
16 months ago

In 55567:

Tests: Add test class for wp_enqueue_stored_styles().

[54214] added the wp_enqueue_stored_styles() tests and clean_up_global_scope() reset global method to Tests_Theme_wpGetGlobalStylesheet.

This changeset relocates those tests a new test class specifically for wp_enqueue_stored_styles() and removes Tests_Theme_wpGetGlobalStylesheet::clean_up_global_scope() method.

Why not relocate the clean_up_global_scope() method to the new test class?
The test class extends from WP_Theme_UnitTestCase which includes this method.

Follow-up to [54214], [54703].

Props costdev.
See #57841.

#10 @hellofromTonya
16 months ago

In 55572:

Tests: Rename test class and improve tests for wp_get_global_stylesheet().

Changes include:

  • Renames the test class to be compliant with test coding standards.
  • Converts the test class to extend WP_Theme_UnitTestCase to reuse test fixtures.
  • Implements data providers to encapsulate datasets and reduce code repetition.
  • Adds a @covers annotation.
  • Improves assertion messages to help with diagnosing failed tests.

Follow-up to [55567], [55148], [52682], [53916], [52675-52677].

Props costdev, hellofromTonya.
See #57841, #57958.

#12 @SergeyBiryukov
16 months ago

In 55581:

Tests: Consistently sanitize expiration in the test suite's Memcached implementation.

In a previous commit, the ::sanitize_expiration() call in the ::add() method was moved closer to where the value is used.

This commit does the same for the other methods:

  • ::cas()
  • ::replace()
  • ::set()
  • ::setMulti()

Follow-up to [40561], [55577].

See #57841, #57963.

#13 @SergeyBiryukov
16 months ago

In 55583:

Tests: Improve get_pages() tests organization.

Includes:

  • Renaming some tests for clarity.
  • Moving some tests to a more appropriate place.
  • Moving the @covers tag to the top of the class.
  • Using consistent formatting for assertion messages.

Follow-up to [27767], [41849], [44587], [55569].

See #57841.

#14 @SergeyBiryukov
16 months ago

In 55588:

Tests: Move the wp_list_pages() test for CSS classes to a more appropriate place.

Back when this test was introduced, wp_list_pages() did not have its own test class.

It does now, so the test can be moved there, instead of being hidden among get_pages() tests.

Includes:

  • Updating the test name for clarity.
  • Adding an unique message for each assertion.

Follow-up to [27755], [28400].

See #57841.

#15 @SergeyBiryukov
16 months ago

In 55589:

Tests: Add a @ticket reference for wp_list_pages() CSS classes test.

Follow-up to [55588].

See #57841.

#16 @SergeyBiryukov
16 months ago

In 55590:

Tests: Move wp_dropdown_pages() tests to their own file.

This aims to make the tests more discoverable and easier to expand.

Includes removing a basic test hidden among get_pages() tests, as there is already a more comprehensive set of tests available.

Follow-up to [1279/tests], [28399], [31338].

See #57841.

#17 @SergeyBiryukov
16 months ago

In 55591:

Tests: Split the tests from post/template.php into individual test classes.

This aims to bring some consistency to the location of post template function tests, as well as to make the tests more discoverable and easier to expand.

Includes:

  • Adding @covers tags.
  • Renaming get_post_parent() and has_post_parent() tests to match the names of the functions.

Follow-up to [28398], [31522], [34654], [34950], [50127], [50396], [54717], [54726], [55590].

See #57841.

#19 @SergeyBiryukov
14 months ago

In 55742:

Tests: Move wp_cache_flush_runtime() next to wp_cache_flush().

This matches the function's placement in wp-includes/cache.php and brings more consistency.

Follow-up to [52772], [55741].

See #57841.

This ticket was mentioned in Slack in #core-committers by spacedmonkey. View the logs.


14 months ago

#21 @spacedmonkey
14 months ago

In 55745:

Tests: Use the function get_num_queries across all unit tests.

Replace use of $wpdb->num_queries with a function call to get_num_queries. This improves readability and consistency between tests.

Props SergeyBiryukov, peterwilsoncc, spacedmonkey.
See #57841.

#22 @spacedmonkey
14 months ago

In 55746:

Tests: Partial revert of r55745

Revert package-lock.json changes committed by mistake in [55745].

Props mukesh27.
See #57841.

@spacedmonkey commented on PR #4438:


14 months ago
#23

Committed.

#24 @SergeyBiryukov
14 months ago

In 55754:

Tests: Split the tests from user/author.php into individual test classes.

This aims to make get_the_author_*() tests more discoverable and easier to expand.

Follow-up to [691/tests], [692/tests], [695/tests], [28362], [31098], [34687], [53147], [54717], [54726], [55591].

See #57841.

#25 @peterwilsoncc
13 months ago

In 55922:

Tests/Build tools: Add @covers annotation to wp_set_object_terms() tests.

Props @costdev.
See #57841.

#26 @peterwilsoncc
13 months ago

In 55924:

Tests/Build tools: Various term related test improvements.

Modifies the tests for get_tag_link(), get_term() and get_term_field() to:

  • use shared fixtures as possible
  • improves variable names
  • add @covers annotation as required

Props peterwilsoncc, costdev.
See #57841.

This ticket was mentioned in PR #4798 on WordPress/wordpress-develop by @ironprogrammer.


13 months ago
#27

Adds a unit test to validate printing of @font-face declarations in a classic theme with a custom font defined in theme.json. Also updates test_font_face_generated_from_themejson() to use a data provider to include the new theme (webfonts-theme-classic).

Previously, only a block theme (webfonts-theme) was subject to this test.

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

#28 @audrasjb
12 months ago

  • Milestone changed from 6.3 to 6.4

Moving to milestone 6.4 as WP 6.3 RC3 has been released.

#29 @SergeyBiryukov
12 months ago

  • Milestone changed from 6.4 to 6.3
  • Resolution set to fixed
  • Status changed from new to closed

See #58955 for 6.4.

Note: See TracTickets for help on using tickets.