Commit Graph

505 Commits

Author SHA1 Message Date
Boone Gorges 7c64b3b3dd Introduced `dayofweek_iso` time param for `WP_Date_Query`.
The initial `dayofweek` param sets day 1 to Sunday. This is out of step with
ISO standards, which calls Monday day 1. To maintain backward compatibility
with the existing parameter, we introduce the new `dayofweek_iso` for the
new, more compliant param.

Props mboynes.
Fixes #28063.

git-svn-id: https://develop.svn.wordpress.org/trunk@30142 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-01 03:23:15 +00:00
Boone Gorges d6b7b7aa41 Allow resource_type to be specified in `get_ancestors()`.
Being explicit about resource type (taxonomy vs post_type) allows for the
proper resolution of conflicts when a taxonomy and post_type share a slug.

Props filosofo.
Fixes #15029.

git-svn-id: https://develop.svn.wordpress.org/trunk@30141 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-01 02:57:31 +00:00
Boone Gorges 8dbaaf9927 Pass all updated meta IDs to filters in `update_metadata()`.
Props wonderboymusic.
Fixes #11683.

git-svn-id: https://develop.svn.wordpress.org/trunk@30140 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-01 02:38:19 +00:00
Scott Taylor bdf61ef6a0 Fix failing unit tests after [30096]: use `assertEqualSets()`.
git-svn-id: https://develop.svn.wordpress.org/trunk@30135 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-01 01:10:39 +00:00
Scott Taylor ff4f545fc9 [28785] introduced a bug, where encoded query arguments were decoded by `parse_str()` inside of `wp_parse_str()` but never re-encoded later on.
This encodes them, adds unit test.

Props obenland.
Fixes #29636.


git-svn-id: https://develop.svn.wordpress.org/trunk@30133 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-01 00:53:26 +00:00
Scott Taylor ef23aee2a6 Fix unit test for video shortcode after [30082].
Fixes #30078.


git-svn-id: https://develop.svn.wordpress.org/trunk@30132 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-01 00:48:32 +00:00
Boone Gorges be87d5daad Move `term_exists()` tests to their own file.
git-svn-id: https://develop.svn.wordpress.org/trunk@30118 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-30 18:52:37 +00:00
Boone Gorges 9a84da90c3 Unserialize `get_metadata()` results when 'key' is omitted.
Props mattkeys, nacin.
Fixes #15030.

git-svn-id: https://develop.svn.wordpress.org/trunk@30115 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-30 10:24:22 +00:00
Jeremy Felt cdc35000f9 Improve tests for domain_exists()
* Split existing tests for `domain_exists()` into many smaller tests.
* Make slightly fewer, more accurate assertions.
* Remove unnecessary site creation via factory.

See #30080


git-svn-id: https://develop.svn.wordpress.org/trunk@30114 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-30 05:43:31 +00:00
Boone Gorges f59f32104a Streamline some `get_terms()` cache tests.
* Split large method into a number of smaller tests.
* Create fewer fixtures.

See #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@30113 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-30 04:15:03 +00:00
Boone Gorges df5e0a00b8 Clean up cache invalidation suspension global in unit tests.
This fixes a test that was introduced in [30073] which was polluting later
tests.

See #21760.

git-svn-id: https://develop.svn.wordpress.org/trunk@30112 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-30 04:14:53 +00:00
Boone Gorges 6a7443671b Clean up `get_term_by()` caching.
* Fix cache key/group modification that was missed in [30073].
* Update unit tests to reflect new key/group format.

Props tollmanz.
Fixes #21760.

git-svn-id: https://develop.svn.wordpress.org/trunk@30108 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-30 02:49:51 +00:00
Boone Gorges cf1d77c101 In `get_terms()`, do not override 'hierarchical' and 'pad_counts' when 'parent' is present.
The previous behavior resulted in descendant terms being improperly excluded
from the results when passing a 'parent', even when 'hierarchical' had been
set to true.

The patch also adds unit tests that demonstrate the various interactions
between the 'child_of', 'parent', and 'hierarchical' parameters of `get_terms()`.

Props landakram.
Fixes #29815.

git-svn-id: https://develop.svn.wordpress.org/trunk@30107 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-30 02:11:56 +00:00
Jeremy Felt 2988aa8ba7 Expand tests around wpmu_delete_blog()
* Test cache after a site is deleted or flagged as deleted.
* Test tables after a site is deleted or flagged as deleted.
* Test tables and cache after the main site is deleted.
* Test site count after a site is deleted or flagged as deleted.

See #30080


git-svn-id: https://develop.svn.wordpress.org/trunk@30106 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-30 01:59:02 +00:00
Boone Gorges f9e32aef2d Use `WP_Comment_Query` to query comments in `get_approved_comments()`.
Props dancameron.
See #12668.

git-svn-id: https://develop.svn.wordpress.org/trunk@30098 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-29 21:57:07 +00:00
Boone Gorges bd795a3d16 Better flexibility for 'type' in `WP_Comment_Query`.
* Add support for an array of values in 'type'.
* Introduce `type__in` parameter. This duplicates 'type' but is added for better consistency with other query classes.
* Introduce `type__not_in`.

Among other things, these changes will make it easier for plugin authors to
manage the appearance of custom comment types in various WP interfaces.

Props dancameron, mordauk.
See #12668.

git-svn-id: https://develop.svn.wordpress.org/trunk@30096 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-29 21:49:08 +00:00
Konstantin Kovshenin 6debe759a6 Use a nested meta query when querying by role in `WP_User_Query`.
If a user query includes a meta query together with a role argument,
nest the original meta query and append the role meta query with an
AND relationship.

fixes #23849, #27026.


git-svn-id: https://develop.svn.wordpress.org/trunk@30094 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-29 21:40:04 +00:00
Boone Gorges 555d7347f9 Support an empty string passed as a status in `WP_Comment_Query`.
The changes in [30084] broke backward compatibility with interfaces that
manually passed an empty string for the value of 'status', such as on
wp-admin/edit-comments.php.

Fixes #29612.

git-svn-id: https://develop.svn.wordpress.org/trunk@30093 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-29 19:50:31 +00:00
Boone Gorges 114c1f32ba Improve global variable setting in `setup_postdata()`.
`setup_postdata()` is responsible for setting a number of global variables
that are used for post pagination (`$pages`, `$page`, `$nextpage`) and the
generation of post excerpts (`$more`). These variables should be sensitive to
the currently running instance of `WP_Query` - rather than the main query -
so that these features work properly inside of secondary `WP_Query` loops.

This changeset moves the logic of `setup_postdata()` into a method on `WP_Query`,
and converts `setup_postdata()` to a wrapper.

Props boonebgorges, wonderboymusic.
See #25349.
Fixes #9256, #20904.

git-svn-id: https://develop.svn.wordpress.org/trunk@30085 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-29 02:31:37 +00:00
Boone Gorges 7c4aada4a6 Support multiple 'status' values in `WP_Comment_Query`.
This change required turning the SQL concatenation into the generation of an
array, for greater flexibility.

Props karpstrucking, ebinnion.
Fixes #29612.

git-svn-id: https://develop.svn.wordpress.org/trunk@30084 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-29 02:21:10 +00:00
Boone Gorges 66e02d639e Remove call to `wp_get_last_changed()` from unit tests.
This function was removed in [30073].

See #21760.

git-svn-id: https://develop.svn.wordpress.org/trunk@30080 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-28 22:02:59 +00:00
Gary Pendergast 0e68ecc0b6 Add `wp_json_encode()`, a wrapper for `json_encode()` that ensures everything is converted to UTF-8.
Change all core calls from `json_encode()` to `wp_json_encode()`.

Fixes #28786.



git-svn-id: https://develop.svn.wordpress.org/trunk@30055 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-28 18:34:16 +00:00
Boone Gorges 6df24465f4 Introduce `orderby=include` support for `get_terms()`.
Props wpsmith.
Fixes #23261.

git-svn-id: https://develop.svn.wordpress.org/trunk@30052 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-28 18:12:30 +00:00
Boone Gorges c6de5dfec5 Allow 'slug' param of `get_terms()` to accept an array.
Props jfarthing84, dlh.
Fixes #23636.

git-svn-id: https://develop.svn.wordpress.org/trunk@30042 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-28 14:56:33 +00:00
Sergey Biryukov cd89f18427 Update expected results in wp_link_pages() unit tests after [30030].
see #24940.

git-svn-id: https://develop.svn.wordpress.org/trunk@30035 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-27 01:58:17 +00:00
Boone Gorges ae0ae95be6 Improve `WP_Tax_Query` param sanitization for empty strings.
When an empty string is passed as one of the clauses in the `$tax_query`
parameter, it should be discarded rather than parsed as a first-order clause.

Props tmtrademark.
Fixes #30117.

git-svn-id: https://develop.svn.wordpress.org/trunk@30031 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-26 22:56:36 +00:00
Boone Gorges 4482d000ba Fix 'count' in `WP_Comment_Query` when using 'meta_query'.
Props heshiming, desaiuditd.
Fixes #23369.

git-svn-id: https://develop.svn.wordpress.org/trunk@30026 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-26 16:45:37 +00:00
Boone Gorges 1345fdbe22 Streamline `WP_User_Query` unit tests.
* Don't create user during setUp(), as it's not used in every test.
* Create fewer users in `get_all` and `orderby` tests.

See #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@30017 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-24 19:51:01 +00:00
Boone Gorges 1fe9707760 Accept 'orderby=include' in `WP_User_Query`.
This lets the results of a user query be sorted manually by the value of the
'include' param.

Props jipmoors.
Fixes #30064.

git-svn-id: https://develop.svn.wordpress.org/trunk@30016 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-24 19:50:53 +00:00
Boone Gorges b450eb023f Improve unit tests for `WP_User_Query` include param.
git-svn-id: https://develop.svn.wordpress.org/trunk@30008 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-24 12:18:44 +00:00
Jeremy Felt 5015f3ed4e Improve tests for get_blog_id_from_url()
Expand tests to cover additional cache and lookup scenarios. Explicitly test the reaction of `get_blog_id_from_url()` when `$drop = false` is passed to `wpmu_delete_blog()`. See #30080

Fixes #30088


git-svn-id: https://develop.svn.wordpress.org/trunk@30007 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-24 05:30:14 +00:00
Jeremy Felt 98a37894d6 Begin cleanup of ms-sites group unit tests
* Split `test_create_and_delete_blog()` into two tests.
* Clean up number of sites created during tests.
* Remove test_getters(), move get_blog_address_by_name() test to `test_created_site_details()`

See #30080


git-svn-id: https://develop.svn.wordpress.org/trunk@30006 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-24 04:50:57 +00:00
Boone Gorges 382871ad9d Allow ORDER BY in `WP_Comment_Query::query()` to be disabled.
Disable ORDER BY by passing boolean false, an empty array, or the string
'none' to the 'orderby parameter. This mirrors the behavior of `WP_Query`.

Props psycleuk.
Fixes #29902.

git-svn-id: https://develop.svn.wordpress.org/trunk@30004 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-24 02:50:24 +00:00
Boone Gorges ce810ba5b3 Add unit tests for WP_Comment_Query 'orderby' param.
For better testability, the SQL string generated in `WP_Comment_Query::get_posts()`
is now stored as a 'request' property on the object.

See #29902.

git-svn-id: https://develop.svn.wordpress.org/trunk@30003 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-24 02:33:46 +00:00
Boone Gorges 1fc0287164 Set current user to 0 after each unit test.
This prevents $current_user, $userdata, and other user-related globals from
being polluted if a previous test does not properly reset the current user.

Props nacin, mnelson4.
Fixes #29712.

git-svn-id: https://develop.svn.wordpress.org/trunk@30001 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-24 00:58:35 +00:00
Boone Gorges 9dafca7e2c Add unit tests for 'append' argument of wp_set_object_terms().
See #29624.

git-svn-id: https://develop.svn.wordpress.org/trunk@29997 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-23 13:52:57 +00:00
Boone Gorges cc41c59286 Streamline WP_Date_Query unit tests.
By creating less dummy data and eliminating redundant tests, we cut group
execution time by more than 50%.

See #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@29993 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-23 01:55:43 +00:00
Boone Gorges 48e77bd87f Generate fewer default posts in wp_list_authors() tests.
Saves about 7 seconds when running the suite.

See #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@29992 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-23 01:14:24 +00:00
Boone Gorges 34f0e3844b Add unit test for `WP_Comment_Query` 'search' param.
git-svn-id: https://develop.svn.wordpress.org/trunk@29982 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-21 14:17:25 +00:00
Boone Gorges a14c675dea Remove redundant unit test for `WP_Comment_Query` 'status'.
This old test is too resource-intensive, and duplicates the more precise
tests introduced in [29980].

See #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@29981 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-21 14:17:17 +00:00
Boone Gorges 11e0a527f7 Improve unit tests for 'status' param in `WP_Comment_Query`.
See #29612.

git-svn-id: https://develop.svn.wordpress.org/trunk@29980 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-21 13:40:33 +00:00
Boone Gorges dc141fc510 Remove failing unit test for #27193.
This ticket was closed as invalid, so we no longer need this test.

git-svn-id: https://develop.svn.wordpress.org/trunk@29979 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-21 13:40:27 +00:00
Dion Hulse 5bcbdefd2e HTTP API: Support both the 'limit_response_size' and 'stream' parameters at the same time, allowing a partial file download.
Fixes #26726


git-svn-id: https://develop.svn.wordpress.org/trunk@29968 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-20 07:31:45 +00:00
Sergey Biryukov 79734b0677 Update expected results in wp_add_inline_style() unit tests after [29958].
props georgestephanis.
see #30032.

git-svn-id: https://develop.svn.wordpress.org/trunk@29967 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-19 21:23:32 +00:00
Boone Gorges 348c8958da Use the comment API rather than direct SQL queries in `comments_template()`.
`comments_template()` is used by most themes to display a post's comments. It
shows all comments that have been approved, and also shows all pending comments
by the current visitor (as determined by the comment cookies). However, the
comments API previously had no way of querying for "all comments that are
either approved, or are unapproved but written by foo@example.com". The
workaround was a direct SQL query: uncached, not subject to the same filters as
other comment queries, and just generally icky.

The new `include_unapproved` parameter for `WP_Comment_Query` accepts an array
of user IDs or email addresses. Pending comments associated with users in this
array will be included in query results, regardless of the value of the 'status'
parameter. In `comments_template()`, we leap from direct SQL queries to
`get_comments()` plus `include_unapproved', striving to put right what once
went wrong.

Props boonebgorges, simonwheatley, hardy101, jesin.
Fixes #19623.

git-svn-id: https://develop.svn.wordpress.org/trunk@29965 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-19 19:38:16 +00:00
Boone Gorges 91733ae919 Make orderby=meta_value compatible with meta_query when relation=OR.
Passing orderby=meta_value and meta_key=foo to WP_Query should require that
each matched post have a meta value with the key 'foo'. To make this
requirement compatible with meta_query params that have the relation OR, we
nest the meta_query param, and join it using AND to a meta_query clause
generated from the meta_key/meta_compare/meta_type query vars.

Fixes #25538.

git-svn-id: https://develop.svn.wordpress.org/trunk@29964 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-19 18:53:55 +00:00
Boone Gorges fd7d38ec3b Ensure that post types and taxonomies are reset between multisite tests.
This is a port of [29869] to multisite.xml.

See #29827.

git-svn-id: https://develop.svn.wordpress.org/trunk@29954 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-18 02:31:46 +00:00
Sergey Biryukov 49c33927b5 Fix formatting in [29946].
props TobiasBg.
fixes #29925.

git-svn-id: https://develop.svn.wordpress.org/trunk@29952 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 22:14:49 +00:00
Aaron Jorbin 230313d25a Check if WP_DEFAULT_THEME starts with twenty before asserting it is in default theme array
This fixes an issue that if you change WP_DEFAULT_THEME and run core unit tests, the tests fail since your theme isn't one of the hard coded lists of default themes. We need to keep this test to make sure that we update the array of default themes for use in other tests.

If we ever change the naming convention for default themes, this will need to be updated.

props nacin for initial idea
fixes #29925



git-svn-id: https://develop.svn.wordpress.org/trunk@29946 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 20:59:23 +00:00
Boone Gorges c2bea27bfd Invalidate cache for child terms when parent term is deleted.
Props socki03.
Fixes #29911.

git-svn-id: https://develop.svn.wordpress.org/trunk@29945 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 20:58:48 +00:00