[wp-trac] [WordPress Trac] #49149: Write tests for WP_Query
WordPress Trac
noreply at wordpress.org
Tue Jan 7 22:30:59 UTC 2020
#49149: Write tests for WP_Query
-------------------------+------------------------------
Reporter: leogermani | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------+------------------------------
Old description:
> WP_Query is one of the most critical classes in WordPress. It holds a lot
> of features and complicated rules to generate the SQL queries to fetch
> posts from the databases.
>
> Working on bug fixes and new features for it is very tricky because one
> is always afraid that any change to it could silently break things and
> tear the world apart.
>
> One way to make us feel more secure when working with this class is to
> have better test coverage for it. Looking at the tests we currently have
> I found very few tests for this class.
>
> I've created this ticket to organize and receive patches to add tests to
> this class.
>
> Below I organized the WP_Query parameters we should, at first, create
> tests for. Once we have tests for them individually, we can think of a
> way to write tests that combine different parameters.
>
> * Author params
> * author
> * author_name
> * author__in
> * author__not_in
>
> * Category params
> * cat
> * category_name
> * category__and
> * category__in
> * category__not_in
>
> * Tag params
> * tag
> * tag_id
> * tag__and
> * tag__in
> * tag__not_in
> * tag_slug__and
> * tag_slug__in
>
> * Tax_query
>
> * Meta_query
>
> * date_query
>
> * post_mime_type
>
> * fields
>
> * name
>
> * page_id
>
> * pagename
>
> * post_parent
>
> * post_parent__in
>
> * post_parent__not_in
>
> * post__in
>
> * post__not_in
>
> * post_name__in
>
> * has_password
>
> * post_password
>
> * post_type
>
> * post_status
>
> * comment_count
>
> * nopaging
>
> * posts_per_page
>
> * offset
>
> * paged
>
> * ignore_sticky_posts
>
> * order and orderby paramaters
>
> PS - what motivated me to open this ticket (and start working on these
> tests) was #48556 and #44737
New description:
WP_Query is one of the most critical classes in WordPress. It holds a lot
of features and complicated rules to generate the SQL queries to fetch
posts from the databases.
Working on bug fixes and new features for it is very tricky because one is
always afraid that any change to it could silently break things and tear
the world apart.
One way to make us feel more secure when working with this class is to
have better test coverage for it. Looking at the tests we currently have I
found very few tests for this class.
I've created this ticket to organize and receive patches to add tests to
this class.
Below I organized the WP_Query parameters we should, at first, create
tests for. Once we have tests for them individually, we can think of a way
to write tests that combine different parameters.
{{{
* Author params
* author
* author_name
* author__in
* author__not_in
* Category params
* cat
* category_name
* category__and
* category__in
* category__not_in
* Tag params
* tag
* tag_id
* tag__and
* tag__in
* tag__not_in
* tag_slug__and
* tag_slug__in
* Tax_query
* Meta_query
* date_query
* post_mime_type
* fields
* name
* page_id
* pagename
* post_parent
* post_parent__in
* post_parent__not_in
* post__in
* post__not_in
* post_name__in
* has_password
* post_password
* post_type
* post_status
* comment_count
* nopaging
* posts_per_page
* offset
* paged
* ignore_sticky_posts
* order and orderby paramaters
}}}
PS - what motivated me to open this ticket (and start working on these
tests) was #48556 and #44737
--
Comment (by SergeyBiryukov):
Thanks for the ticket!
> One way to make us feel more secure when working with this class is to
have better test coverage for it. Looking at the tests we currently have I
found very few tests for this class.
At a glance, most of the existing tests appear to be in these files,
somewhat grouped by component:
* [source:tags/5.3.2/tests/phpunit/tests/query/] (specific methods or
parameters)
* [source:tags/5.3.2/tests/phpunit/tests/date/query.php]
* [source:tags/5.3.2/tests/phpunit/tests/meta/query.php]
* [source:tags/5.3.2/tests/phpunit/tests/post/query.php]
* [source:tags/5.3.2/tests/phpunit/tests/term/query.php]
* [source:tags/5.3.2/tests/phpunit/tests/term/taxQuery.php]
* [source:tags/5.3.2/tests/phpunit/tests/meta.php]
* [source:tags/5.3.2/tests/phpunit/tests/query.php]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49149#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list