wordpress-develop/tests/phpunit/tests/query
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
..
commentCount.php Build/Test Tools: Reduce the use of unnecessary randomness in tests. 2021-12-19 13:42:37 +00:00
commentFeed.php Query: Add tests following [53065]. 2022-04-05 01:59:52 +00:00
conditionals.php Query: Check if $wp_query is set in query loop functions. 2022-05-22 15:15:47 +00:00
date.php Build/Test Tools: Implement use of the void solution. 2021-08-07 10:29:41 +00:00
dateQuery.php Build/Test Tools: Implement use of the void solution. 2021-08-07 10:29:41 +00:00
generatePostdata.php Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests. 2020-09-02 00:35:36 +00:00
invalidQueries.php Tests: Avoid duplicate queries in some WP_Query tests. 2022-01-14 17:50:52 +00:00
isTerm.php Coding Standards: Add visibility to methods in tests/phpunit/tests/. 2021-11-04 15:22:47 +00:00
metaQuery.php Coding Standards: Fix WPCS issues in [51367]. 2021-07-07 10:50:43 +00:00
noFoundRows.php Tests: Replace assertContains() with assertStringContainsString() when used with strings. 2021-07-19 14:00:11 +00:00
parseQuery.php Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests. 2020-09-02 00:35:36 +00:00
postStatus.php Build/Test Tools: Implement use of the void solution. 2021-08-07 10:29:41 +00:00
results.php Coding Standards: Add visibility to methods in tests/phpunit/tests/. 2021-11-04 15:22:47 +00:00
search.php Build/Test Tools: Reduce the use of unnecessary randomness in tests. 2021-12-19 13:42:37 +00:00
setupPostdata.php Coding Standards: Add visibility to methods in tests/phpunit/tests/. 2021-11-04 15:22:47 +00:00
stickies.php Query: Ensure that sticky post query returns all sticky posts. 2022-03-25 09:54:52 +00:00
taxQuery.php Taxonomy: Improve performance by taxonomy queries by adding a limitting requested terms. 2022-03-31 10:04:25 +00:00
vars.php Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests. 2020-09-02 00:35:36 +00:00
verboseRewriteRules.php Coding Standards: Add visibility to methods in tests/phpunit/tests/. 2021-11-04 15:22:47 +00:00