4896 Commits

Author SHA1 Message Date
Sergey Biryukov
c13b9ba752 Tests: Temporarily disable the failing REST API test for update_post_parent_caches().
This needs more investigation to address the test failure with persistent object cache.

Follow-up to [53506].

Props hellofromTonya.
See #55593.

git-svn-id: https://develop.svn.wordpress.org/trunk@53511 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-15 15:37:09 +00:00
Sergey Biryukov
5b048f5a4e Tests: Use assertSameSets() in some newly introduced tests.
This ensures that not only the array values being compared are equal, but also that their type is the same.

Going forward, stricter type checking by using `assertSameSets()` or `assertSameSetsWithIndex()` should generally be preferred, to make the tests more reliable.

Follow-up to [48939], [51137], [51943], [53499], [53504], [53506], [53509].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53510 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-15 14:42:58 +00:00
Sergey Biryukov
8f219cdd78 Tests: Some improvements for REST API cache priming tests:
* Give the test methods more specific names and move them closer together.
* Correct the `@covers` tags.

Follow-up to [53499], [53504], [53506], [53507], [53508].

See #55593, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53509 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-15 14:07:24 +00:00
Sergey Biryukov
ec0f508a9f REST API: Some documentation and test improvements for update_menu_item_cache():
* Make the function description more specific, for consistency with other similar functions.
* Add a `@since` note for the `$update_menu_item_cache` parameter of `WP_Query::parse_query()`.
* Add missing `@covers` tags for the unit tests.

Follow-up to [53504].

See #55620.

git-svn-id: https://develop.svn.wordpress.org/trunk@53508 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-15 13:35:28 +00:00
Sergey Biryukov
20ccbb1437 REST API: Some documentation and test improvements for update_post_parent_caches():
* Make the function description more specific, for consistency with `update_post_author_caches()`.
* Add missing `@covers` tags for the unit test.

Follow-up to [53506].

See #55593.

git-svn-id: https://develop.svn.wordpress.org/trunk@53507 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-15 13:17:59 +00:00
Jonny Harris
9a488568a0 REST API: Prime caches for post parents in post REST API controller.
Prime caches for all post parents in the post REST API controller using the `_prime_post_caches` function. Post parent objects are required as part of the `check_read_permission` method’s permission check in post REST API controller. 

Props spacedmonkey, furi3r, peterwilsoncc, mitogh, madpixels. 
Fixes #55593.

git-svn-id: https://develop.svn.wordpress.org/trunk@53506 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-15 10:41:32 +00:00
Jonny Harris
aef77be627 REST API: Prime caches for linked objects in menu item REST API controller.
Add a new parameter to `WP_Query` called `update_menu_item_cache` that when set to true, primes the caches for linked terms and posts for menu item post objects. This change moves logic 
found in `wp_get_nav_menu_items` into a new function called `update_menu_item_cache`.  Update the menu item REST API controller, to pass the `update_menu_item_cache` parameter to the 
arguments used for the  `WP_Query` run to get menu items. 

Props furi3r,  TimothyBlynJacobs, spacedmonkey, peterwilsoncc, mitogh.
Fixes #55620.

 --This line, and those below, will be ignored--

M    src/wp-includes/class-wp-query.php
M    src/wp-includes/nav-menu.php
M    src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php
M    tests/phpunit/tests/post/nav-menu.php


git-svn-id: https://develop.svn.wordpress.org/trunk@53504 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-15 10:18:02 +00:00
Jonny Harris
c2de42b9ad REST API: Prime caches for featured images in post controller.
Ensure that featured image caches are primed for post collections in the post REST API controller, by calling the `update_post_thumbnail_cache` function. 

Props Spacedmonkey, TimothyBlynJacobs, mitogh.
Fixes #55592. 



git-svn-id: https://develop.svn.wordpress.org/trunk@53499 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-14 13:08:39 +00:00
Jonny Harris
219927c11b REST API: Avoid duplicated query in post collections.
Avoid duplicated query when retrieving empty posts collections by adding a check if the page is more than 1. 

Props furi3r, gdetassigny, TimothyBlynJacobs, spacedmonkey. 
Fixes #55677.



git-svn-id: https://develop.svn.wordpress.org/trunk@53498 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-14 12:40:29 +00:00
Sergey Biryukov
a067d588c3 Tests: Remove redundant skip call in Tests_Image_Functions::get_image_editor_engine_classes().
The test bootstrap requires GD to be available, so this test skip condition will never be matched.

Also, test skipping from within a helper method, which may be used in a data provider, can lead to test runtime errors.

Follow-up to [49009], [49014], [49535], [49571], [51415].

Props jrf.
See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53497 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-14 11:44:58 +00:00
Jonny Harris
6d89ea8f09 Taxonomy: Fix caching issues in WP_Term_Query class.
Introduced [52836] when passing `child_of` or `pad_counts` parameters to `get_terms` or `WP_Term_Query` class, the array of terms received by the query, was not correctly cached. This 
change simplifies the logic in `WP_Term_Query` and ensures terms are correctly cached. This change also, improves performance, by only caching an array of term ids where possible.  

Props denishua, spacedmonkey, oztaser, peterwilsoncc, SergeyBiryukov, georgestephanis, jnz31, knutsp, mukesh27, costdev.
Fixes #55837.



git-svn-id: https://develop.svn.wordpress.org/trunk@53496 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-14 11:41:33 +00:00
Sergey Biryukov
2aa8e490e0 Tests: Move helper functions in Tests_Image_Functions to more appropriate places.
* Move a non-test specific helper function used by multiple tests up to the top of the class to make it more easily discoverable.
* Move a test-specific helper function used by only one test to be directly below the test using the helper function and make the link with the test explicit by adding a `@see` tag.

Follow-up to [1201/tests], [51415].

Props jrf.
See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53495 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-13 16:42:17 +00:00
Sergey Biryukov
c33e34d8a5 Tests: Rename classes in phpunit/tests/option/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639], [51646], [51650], [51651], [51860], [52264], [52265], [53489].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53494 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-13 15:24:11 +00:00
Sergey Biryukov
cde9366b3a Tests: Add a unit test for PHP 8.1 deprecation notice in wp_user_settings().
This ensures that PHP 8.1 "passing null to non-nullable" deprecation notice is not thrown for the `$domain` parameter of `setcookie()` calls in the function.

Follow-up to [53490].

See #54914.

git-svn-id: https://develop.svn.wordpress.org/trunk@53493 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-13 15:20:02 +00:00
Sergey Biryukov
26d3ef0bf0 Tests: Use more consistent wording when referring to PHP deprecation notices.
Follow-up to [51619], [51695].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53492 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-13 14:51:33 +00:00
Sergey Biryukov
2f8a627bd1 Tests: Use a consistent URL in HTTP response cookie tests.
Follow-up to [34369], [35734], [38164].

See #51568.

git-svn-id: https://develop.svn.wordpress.org/trunk@53491 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-12 15:16:09 +00:00
Sergey Biryukov
32cbb46a21 Tests: Rename classes in phpunit/tests/user/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639], [51646], [51650], [51651], [51860], [52264], [52265].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53489 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-11 15:48:31 +00:00
Sergey Biryukov
be413a98e9 Tests: Re-initialize WP_Rewrite before running wp_list_authors() tests.
This ensures that the expected results use the default permalink structure, not affected by other tests.

Follow-up to [27550], [27684], [53487].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53488 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-11 15:34:35 +00:00
Sergey Biryukov
3308ae7e4f Tests: Rename the test file and class for wp_list_authors() tests.
This matches the name of the function being tested.

Follow-up to [27550].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53487 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-11 13:41:45 +00:00
Jonny Harris
b855e63693 REST API: Improve post cache priming in WP_REST_Post_Search_Handler class.
In the `WP_REST_Post_Search_Handler` class, ensure that post, post meta and term caches are correctly primed when performing a search.

Props furi3r, spacedmonkey, TimothyBlynJacobs, audrasjb, peterwilsoncc. 
Fixes #55674.



git-svn-id: https://develop.svn.wordpress.org/trunk@53485 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-10 15:45:45 +00:00
Sergey Biryukov
de009085a9 Query: Some documentation and test improvements for update_post_author_caches():
* Make the descriptions for `update_post_author_caches()` and `update_post_caches()` more specific.
* Move the unit test into its own file, for consistency with `update_post_cache()` tests. This also allows for using shared fixtures in case more tests are added in the future.

Follow-up to [53482].

See #55716.

git-svn-id: https://develop.svn.wordpress.org/trunk@53483 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-10 15:15:07 +00:00
Jonny Harris
aff6a79b27 Prime users cache in WP_Query and post REST API controller.
For a call to `WP_Query` or a post REST API request that contains posts from multiple authors, call the `cache_users` function, to ensure that all user data for post authors is primed in 
a single database query. This results in far fewer database queries on multiple author sites. 

Props spacedmonkey, timothyblynjacobs, peterwilsoncc.
Fixes #55716.


git-svn-id: https://develop.svn.wordpress.org/trunk@53482 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-10 13:37:52 +00:00
Sergey Biryukov
f52d476bc6 Media: Some documentation and test improvements for wp_img_tag_add_decoding_attr():
* Add a `@since` note for the `decoding` attribute in `wp_get_attachment_image()`.
* Adjust `wp_img_tag_add_decoding_attr()` DocBlocks per the documentation standards.
* Wrap some long `sprintf()` calls in unit tests for better readability. In at least one case, `the_content` was unnecessarily passed to `sprintf()` as an extra (unused) parameter.

Follow-up to [53480].

See #53232.

git-svn-id: https://develop.svn.wordpress.org/trunk@53481 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-09 16:19:39 +00:00
Peter Wilson
270259115c Media: Add decoding="async" to image attributes.
Dynamically add `decoding="async"` to image tags on the front end of a site to instruct browsers to download them in parallel.

Modifies `wp_get_attachment_image()`, `get_avatar()` to include the attribute by default. Modifies `wp_filter_content_tags()` to add the attribute during the front-end render of the site.

Introduces `wp_img_tag_add_decoding_attr()` to take an image tag and modify it to include the attribute. Introduces the filter `wp_img_tag_add_decoding_attr` used to define the default value for the attribute.

Props adamsilverstein, ayeshrajans, costdev, flixos90, hellofromtonya, isaumya, michaelbourne, mihai2u, mitogh, sergiomdgomes, spacedmonkey, westonruter, peterwilsoncc.
Fixes #53232.


git-svn-id: https://develop.svn.wordpress.org/trunk@53480 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-09 05:29:57 +00:00
Sergey Biryukov
fc121d69e9 Tests: Correct an assertion in wp_rand() tests.
The function returns non-negative integers, which includes zero.

Follow-up to [53473], [53477].

See #55194.

git-svn-id: https://develop.svn.wordpress.org/trunk@53479 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-08 13:17:27 +00:00
Sergey Biryukov
89cc0f5d95 Tests: Move the tests for individual pluggable functions into their own directory.
This aims to make the tests more discoverable and easier to expand.

Follow-up to [50790], [53473], [53477].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53478 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-07 14:44:00 +00:00
Sergey Biryukov
e907a66546 Tests: Use more descriptive names for wp_rand() test methods.
This aims to clarify the intention of the tests.

Follow-up to [53473].

Props mlajo, costdev, acoulombe, azouamauriac, swissspidy, tobifjellner, peterwilsoncc, audrasjb, marekdedic, SergeyBiryukov.
See #55194.

git-svn-id: https://develop.svn.wordpress.org/trunk@53477 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-07 12:01:09 +00:00
Jb Audras
a147212892 General: Ensure wp_rand() returns 0 when $min and $max values are equal to 0.
This changeset ensures `wp_rand()` returns zero instead of a random number when both `$min` and `$max` values are equal to zero.

Fixes #55194.


git-svn-id: https://develop.svn.wordpress.org/trunk@53473 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-06 22:48:21 +00:00
Sergey Biryukov
50fab6f6b4 Tests: Update the URL to the documentation on GitHub Actions environment variables.
Follow-up to [49264].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53467 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-05 14:04:39 +00:00
Sergey Biryukov
80ca807a96 Tests: Don't overwrite image metadata in a wp_calculate_image_srcset() test for zero width.
This was unnecessarily replacing the original image metadata with a scaled version, leading to a few leftover images with the `-scaled` suffix in the `wp-content/uploads` directory.

Follow-up to [35412].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53465 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-04 18:03:56 +00:00
Sergey Biryukov
d67674512e Tests: Consistently pass the $force_delete parameter to wp_delete_attachment().
Convert some `wp_delete_post()` calls to `wp_delete_attachment()` to avoid an extra function call.

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53464 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-04 13:39:17 +00:00
Sergey Biryukov
82d1e32a10 Tests: Clean up test images before performing assertions in image resize tests.
This makes sure there are no leftover images in case of a test failure.

Follow-up to [161/tests], [1255/tests].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53463 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-04 12:55:15 +00:00
Sergey Biryukov
c08eca3589 Tests: Add some test cases for path_join() with Windows paths.
Follow-up to [6984], [53457], [53460].

Props joyously.
See #55897.

git-svn-id: https://develop.svn.wordpress.org/trunk@53461 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-03 15:05:28 +00:00
Sergey Biryukov
153a886eaf Tests: Add unit tests for path_join().
Props karlijnbk.
See #55897.

git-svn-id: https://develop.svn.wordpress.org/trunk@53457 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-02 14:58:38 +00:00
Sergey Biryukov
b316c8b25f General: Replace all esc_url_raw() calls in core with sanitize_url().
This aims to improve performance by calling `sanitize_url()` directly, instead of the `esc_url_raw()` wrapper. As of WordPress 6.1, `sanitize_url()` is the recommended function for sanitizing a URL for database or redirect usage.

Follow-up to [11383], [13096], [51597], [53452].

Props benjgrolleau, peterwilsoncc, SergeyBiryukov.
Fixes #55852.

git-svn-id: https://develop.svn.wordpress.org/trunk@53455 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-01 18:12:25 +00:00
Sergey Biryukov
c59af567e5 Tests: Require the zip PHP extension in block templates export file test.
This avoids a test failure if the `ZipArchive` class is missing.

Additionally, this commit replaces an inline check for the `ZipArchive` class in personal data export file tests with a `@requires` annotation, for consistency with similar PHP extension requirements in other tests.

Follow-up to [44786], [51415], [52286].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53454 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-01 14:16:39 +00:00
Sergey Biryukov
ad4a3ad33e Coding Standards: Correct alignment in various files.
This fixes an `Equals sign not aligned correctly` WPCS warning.

Additionally, this commit sets the `svn:eol-style` property for the `phpunit/tests/ajax/wpAjaxCropImage.php` file and corrects line endings, so that the output of `composer format` is clean.

Follow-up to [53027], [53217], [53404].

Props hellofromTonya, SergeyBiryukov.
See #55647.

git-svn-id: https://develop.svn.wordpress.org/trunk@53441 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-23 20:38:02 +00:00
Sergey Biryukov
bc161e6c82 General: Bump the recommended MariaDB version in readme.html.
MariaDB 10.2 has reached EOL in May 2022. The recommended minimum is bumped to 10.3 for now.

Follow-up to [52319], [52358], [52420], [52424], [53431], [53433], [meta11866].

Props hellofromTonya.
Fixes #55791. See #meta6322.

git-svn-id: https://develop.svn.wordpress.org/trunk@53435 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-23 14:20:47 +00:00
Sergey Biryukov
1d62e1f2fb Tests: Improve the assertions in recommended MySQL and MariaDB version tests.
Comparing human-readable dates instead of numeric timestamps gives identical results, but makes the message more clear in case of failure.

Follow-up to [33946], [52418], [52421], [52424].

See #55791, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53433 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-23 14:07:47 +00:00
Tonya Mork
214d4a9073 Build/Test Tools: Temporarily skip MariaDB version test.
TEMPORARY COMMIT.

MariaDB version 10.2 is no longer supported as of 23 May 2022. This commit temporarily skips the version test. Why? To avoid test failures during this period, i.e. until the version is bummped and `readme.html` file changed.

See #55791, [https://meta.trac.wordpress.org/ticket/5999 Meta5999].

git-svn-id: https://develop.svn.wordpress.org/trunk@53431 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-23 13:30:13 +00:00
Tonya Mork
edf3f48e04 Build/Test Tools: Fix comments odd/even instabilities (test leaks).
The odd / even class attribute global variables are causing issues in comments tests when a new test is added or an existing test is modified. To stabilize the odd / even comment tests, the comment global variables are added to the base test class' `tear_down()` using the same patterns as the other global resets. This change ensures each comment test starts at the same state. In doing so, the expected odd / even class attributes are no longer affected by previous tests, i.e. test leaks.

Follow-up to [53172].

Props hellofromTonya, zieladam, peterwilsoncc.
See #54725.

git-svn-id: https://develop.svn.wordpress.org/trunk@53430 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-23 11:54:28 +00:00
Sergey Biryukov
2c06c9afd5 Query: Check if $wp_query is set in query loop functions.
This avoids a PHP fatal error if any of these functions are called too early:

* `have_posts()`
* `in_the_loop()`
* `rewind_posts()`
* `the_post()`
* `have_comments()`
* `the_comment()`

bringing some consistency with conditional tags: `is_single()`, `is_home()`, etc.

This commit also removes unnecessary `return` from `the_comment()`, for consistency with `the_post()`. As `WP_Query::the_comment()` does not have a return value, this statement did not have any effect in practice.

Follow-up to [4934], [8807], [16947], [17068], [17083], [49147], [53395], [53396], [53400].

Props vdankbaar, thijso, teunvgisteren, timkersten655, SergeyBiryukov.
Fixes #55722.

git-svn-id: https://develop.svn.wordpress.org/trunk@53429 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-22 15:15:47 +00:00
Sergey Biryukov
5a49274a92 Code Modernization: Replace phpversion() function calls with PHP_VERSION constant.
`phpversion()` return value and `PHP_VERSION` constant value are identical, but the latter is several times faster because it is a direct constant value lookup compared to a function call.

Props ayeshrajans, jrf, mukesh27, costdev, hellofromTonya, SergeyBiryukov.
Fixes #55680.

git-svn-id: https://develop.svn.wordpress.org/trunk@53426 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-20 17:36:23 +00:00
Peter Wilson
72bc35114b Themes: Accept valid block themes.
Updates theme validation to accept block themes. This replaces the requirement for an `index.php` with a requirement for either an `index.php`, `/templates/index.html` or the deprecated `/block-templates/index.html`.

Validation is updated for theme uploads, within `WP_Theme::__construct` and `validate_current_theme()`. 

A block theme using the deprecated file structure is now included in the unit tests.

Props peterwilsoncc, sergeybiryukov, hellofromtonya, costdev, azaozz, gziolo, FlorianBrinkmann, Boniu91, aristath, poena, audrasjb.
Fixes #55754.


git-svn-id: https://develop.svn.wordpress.org/trunk@53416 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-20 00:47:45 +00:00
Sergey Biryukov
590ca0ff94 Users: Fail gracefully when checking mapped capabilities without providing the required object ID.
This avoids an `Undefined array key 0` PHP warning for `current_user_can()` capability checks that require a specific object to check against but an object ID was not passed.

A `_doing_it_wrong()` notice is also added, so that developers and site administrators are aware that the capability mapping is failing in the absence of the required object ID.

The list of mapped capabilities that require an object ID:

* `delete_post` / `delete_page`
* `edit_post` / `edit_page`
* `read_post` / `read_page`
* `publish_post`
* `edit_(post|comment|term|user)_meta` / `delete_*_meta` / `add_*_meta`
* `edit_comment`
* `edit_term` / `delete_term` / `assign_term`

Follow-up to [34091], [34113], [47178].

Props jeherve, peterwilsoncc, henry.wright, johnbillion, mattheweppelsheimer, hellofromTonya, JeffPaul, azouamauriac, Ninos Ego, TobiasBg, wpsmith, GaryJ, nacin, johnstonphilip, azaozz, SergeyBiryukov.
Fixes #44591.

git-svn-id: https://develop.svn.wordpress.org/trunk@53408 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-17 18:59:24 +00:00
Sergey Biryukov
cfc71d580f Tests: Use a data provider in the test for conditional tags returning early if $wp_query is not set.
Follow-up to [53395], [53396].

Props peterwilsoncc.
See #55104.

git-svn-id: https://develop.svn.wordpress.org/trunk@53400 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-16 14:09:41 +00:00
Sergey Biryukov
183dc1a347 Tests: Expand the test for conditional tags returning early if $wp_query is not set.
When called too early, conditional query tags should throw a `_doing_it_wrong()` notice and return `false`. This commit verifies that behavior not only for `is_main_query()`, but for all the other conditional tags too.

Follow-up to [16947], [17068], [17083], [18699], [37985], [53395].

See #55104.

git-svn-id: https://develop.svn.wordpress.org/trunk@53396 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-15 15:55:11 +00:00
Sergey Biryukov
3da312a954 Query: Check if $wp_query is set in is_main_query().
This avoids a PHP fatal error and triggers a `_doing_it_wrong()` notice if `is_main_query()` is called too early, bringing consistency with all the other `is_*()` conditionals: `is_single()`, `is_home()`, etc.

Follow-up to [16947], [17068], [17083], [18699], [37985].

Props vdankbaar, nhadsall, johnbillion, costdev, thijsoo, teunvgisteren, timkersten655, SergeyBiryukov.
Fixes #55104.

git-svn-id: https://develop.svn.wordpress.org/trunk@53395 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-14 15:08:58 +00:00
Tonya Mork
c70e76772c Editor: Use stricter assertions in comment template tests.
Backport of the remaining Comment Template block tests from Gutenberg:

* `assertEquals()` replaced with `assertSameSetsWithIndex()`.
* assertion's argument order changed to ensure expected and then actual.

Follow-up to [53353], [53298], [53172], [53138].

Props bernhard-reiter.
Fixes #55708.

git-svn-id: https://develop.svn.wordpress.org/trunk@53388 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-10 21:28:18 +00:00
Peter Wilson
a80c501fb7 Users: Improve WP_User_Query tests following [53362].
Props SergeyBiryukov.
See #53177.



git-svn-id: https://develop.svn.wordpress.org/trunk@53373 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-10 05:47:35 +00:00