Commit Graph

531 Commits

Author SHA1 Message Date
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
Andrew Ozz a454872630 TinyMCE: update to 4.1.6+. Adds support for cache-busting when auto-loading JS and CSS. Change the tests to run in /build. Changelog: https://github.com/tinymce/tinymce/blob/master/changelog.txt.
Fixes #30079

git-svn-id: https://develop.svn.wordpress.org/trunk@29994 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-23 02:07:15 +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
Boone Gorges 1708a580fd Overhaul SQL generating logic in WP_Meta_Query to avoid unnecessary table joins.
The logic used to generate clause SQL in `WP_Meta_Query` is somewhat arcane,
stemming mostly from an ongoing effort to eliminate costly table joins when
they are not necessary. By systematizing the process of looking for shareable
joins - as was done in `WP_Tax_Query` [29902] - it becomes possible to simplify
the construction of SQL queries in `get_sql_for_clause()`. Moreover, the
simplified logic is actually considerably better at identifying shareable
joins, such that certain uses of `WP_Meta_Query` will see joins reduced by 50%
or more.

Includes integration tests for a representative cross-section of the query
clause combinations that result in shared table aliases.

Props boonebgorges, sc0ttkclark.
See #24093.

git-svn-id: https://develop.svn.wordpress.org/trunk@29940 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 20:20:04 +00:00
Scott Taylor be59c5009e `wp_schedule_single_event()` should not prevent scheduling a future duplicate event. It should only reject an event as a duplicate if there is already a similar event scheduled within 10 minutes of the given timestamp.
Adds unit tests, fixes existing cron test.

Props tellyworth.

See [9181], #6966.
Fixes #28213.


git-svn-id: https://develop.svn.wordpress.org/trunk@29939 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 19:16:26 +00:00
Jeremy Felt 611a4aa969 Improve and reduce tests for get_blogs_of_user()
* Create half as many factory sites. See #30017
* Test the removal of a user from multiple sites.
* Expand tests to include second parameter for flagged sites.
* Remove duplicate test for deleted user.

Fixes #29996


git-svn-id: https://develop.svn.wordpress.org/trunk@29937 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 03:01:21 +00:00
Boone Gorges 00f7ae376a Better "inclusive" support for string values in WP_Date_Query.
The 'inclusive' parameter for WP_Date_Query determines whether non-precise
dates for 'before' and 'after' will be rounded up or down. Previously, this was
supported only when 'before' and 'after' were arrays; string-formatted dates
were run through strtotime(), which rounded them all down (inclusive in the
case of after, non-inclusive in the case of before). Now, we attempt to parse
formats that look like MySQL-formatted date strings, and apply inclusive logic
to them if we recognize them successfully.

Fixes #29908.
string values. Array values support the 'inclusive

git-svn-id: https://develop.svn.wordpress.org/trunk@29936 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 02:27:44 +00:00
Boone Gorges aee4647da0 Comment/post author in/not_in for `WP_Comment_Query`.
Props nofearinc, chriscct7.
Fixes #29885.

git-svn-id: https://develop.svn.wordpress.org/trunk@29935 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 01:57:18 +00:00
Boone Gorges 64bc8466db Support date_query by user_registered in WP_User_Query.
Props ChriCo, nacin.
Fixes #27283.

git-svn-id: https://develop.svn.wordpress.org/trunk@29934 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 01:36:36 +00:00
Boone Gorges 42646e67b3 Use table aliases for columns in SQL generated by WP_Date_Query.
The use of non-aliased column names (eg 'post_date' instead of 'wp_posts.post_date')
in WP_Date_Query causes SQL notices and other failures when queries involve
table joins, such as date_query combined with tax_query or meta_query. This
changeset modifies WP_Date_Query::validate_column() to add the table alias when
it can be detected from the column name (ie, in the case of core columns).

A side effect of this change is that it is now possible to use WP_Date_Query
to build WHERE clauses across multiple tables, though there is currently no
core support for the automatic generation of the necessary JOIN clauses. See

Props ew_holmes, wonderboymusic, neoxx, Viper007Bond, boonebgorges.
Fixes #25775.

git-svn-id: https://develop.svn.wordpress.org/trunk@29933 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 01:19:03 +00:00
Boone Gorges 8692199bb5 Add expectedIncorrectUsage flags for unit tests that generate invalid dates.
Since [29925], passing an invalid date to WP_Date_Query will generate a
_doing_it_wrong() notice. The current changeset adds the
`@expectedIncorrectUsage` flag to those existing unit tests that generate
invalid dates, such as those that test canonical redirect and is_404()
conditionals.

Fixes #25834.

git-svn-id: https://develop.svn.wordpress.org/trunk@29932 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-17 00:40:06 +00:00
Boone Gorges 44bb383371 Remove invalid `continue` calls from WP_Tax_Query::get_sql_for_clause().
This was leftover code from the previous implementation, which used a `foreach()`
loop. See [29901].

Props nofearinc.
See #29738, #29718.

git-svn-id: https://develop.svn.wordpress.org/trunk@29931 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-16 22:06:46 +00:00
Boone Gorges a3da10deb0 Throw notices when invalid date values are passed to WP_Date_Query.
`_doing_it_wrong()` notices are now generated when passing out-of-range values
(`month=13`) or invalid dates (`2014-02-29`).

Includes unit tests.

Props ChriCo.
Fixes #25834.

git-svn-id: https://develop.svn.wordpress.org/trunk@29925 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-16 20:11:13 +00:00
Boone Gorges a3e0c08f2f Introduce nested query support to WP_Date_Query.
This enhancement makes it possible to filter post, comment, and other queries
by date in ways that are arbitrarily complex, using mixed AND and OR relations.

Includes unit tests for the new syntax. In a few places, the existing unit
tests were slightly too strict (such as when checking the exact syntax of a SQL
string); these existing tests have been narrowed.

Props boonebgorges.
Fixes #29822.

git-svn-id: https://develop.svn.wordpress.org/trunk@29923 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-16 19:33:24 +00:00
Jeremy Felt f0b35fe7d5 Split and organize multisite unit tests
* Move `ms.php` to `multisite.php`
* Create `multisite.php` under directories `option/` and `user/` to better match existing structure.
* Create a `multisite/` directory containing `bootstrap.php`, `site.php`, and `network.php` for very multisite specific testing.
* Add unit test groups ms-site, ms-user, ms-option, ms-network, and ms-bootstrap.

Fixes #29896


git-svn-id: https://develop.svn.wordpress.org/trunk@29916 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-16 05:06:22 +00:00
Scott Taylor 0d58d32462 Cache `get_term_by()` calls:
* Add a helper function, `wp_get_last_changed()`, to retrieve a last-modified timestamp by cache group
* When caching a term, also make cache entries for slug and name via `slug:{$term_id}` and `name:{$term_id}` keys in the `$taxonomy:$last_changed` bucket that reference the term_id
* In `clean_term_cache()` and `update_term_cache()`, respect `$_wp_suspend_cache_invalidation`
* Original term cache entries maintain BC

Adds unit tests.

Props wonderboymusic, tollmanz, boonebgorges.
Fixes #21760.


git-svn-id: https://develop.svn.wordpress.org/trunk@29915 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-16 04:44:13 +00:00
Scott Taylor 248fc182b8 Fix `Tests_Paginate_Links` tests by properly setting up / tearing down permalink structure.
Props jorbin.
Fixes #29636.


git-svn-id: https://develop.svn.wordpress.org/trunk@29913 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-16 04:22:16 +00:00
Boone Gorges e36cac6794 Check that search value is scalar before parsing.
Prevents PHP notices when non-scalar values are passed.

Includes unit tests.

Props tivnet.
Fixes #29736.

git-svn-id: https://develop.svn.wordpress.org/trunk@29912 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-16 03:31:27 +00:00
Boone Gorges d4239b67da Fix test_build_mysql_datetime_datetime_non_array().
The expected value was being incorrectly built.

git-svn-id: https://develop.svn.wordpress.org/trunk@29906 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-15 17:52:05 +00:00
Boone Gorges 56c82e534f Avoid redundant table joins in WP_Tax_Query.
IN clauses that are connected by OR require only a single table join. To avoid
extraneous joins, keep track of generated table aliases, and let sibling
clauses piggy-back on those aliases when possible.

Introduces WP_Tax_Query::sanitize_relation() to reduce some repeated code.

Adds unit tests to verify the JOIN consolidation, and integration tests for
cases where JOINS are being combined.

Props boonebgorges, otto42, jakub.tyrcha.
Fixes #18105.

git-svn-id: https://develop.svn.wordpress.org/trunk@29902 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-15 16:39:19 +00:00
Boone Gorges 2796b6969f Support 'EXISTS' and 'NOT EXISTS' in `WP_Tax_Query`.
These new values for the 'operator' parameter make it possible to filter items
that have no term from a given taxonomy, or any term from a given taxonomy.

Includes unit tests.

Fixes #29181.

git-svn-id: https://develop.svn.wordpress.org/trunk@29896 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-15 00:53:22 +00:00
Andrew Nacin 209a4c6a86 Set Twenty Fifteen as the new default theme. see #29799.
git-svn-id: https://develop.svn.wordpress.org/trunk@29895 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-14 19:57:13 +00:00
Andrew Nacin 3640f40a12 Fix theme support unit test added in [27220].
The test assumed that the active theme either had no menu locations, or a subset of 'primary' and 'secondary'. see #26900.


git-svn-id: https://develop.svn.wordpress.org/trunk@29894 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-14 19:54:03 +00:00
Boone Gorges 6d94c2e30d Introduce support for nested queries in WP_Tax_Query.
Previously, tax query arguments could be joined by a single AND or OR relation.
Now, these queries can be arbitrarily nested, allowing clauses to be linked
together with multiple relations.

In a few places, WP_Query runs through a list of clauses in a tax_query in order
to set certain query vars for backward compatibility. The necessary changes have
been made to WP_Query to support this feature with the new complex structure of
tax_query. Unit tests are included for these backward compatibility fixes.

Unit tests for the new nesting syntax are included.

Props boonebgorges.
Fixes #29718. See #29738.

git-svn-id: https://develop.svn.wordpress.org/trunk@29891 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-14 04:02:41 +00:00
Boone Gorges 40dc982a30 Use only LEFT JOINs when a meta_query contains a NOT EXISTS clause.
Mixing LEFT and INNER JOIN in these cases results in posts with no metadata
being improperly excluded from results.

Props johnrom.
Fixes #29062.

git-svn-id: https://develop.svn.wordpress.org/trunk@29890 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-14 02:16:28 +00:00