Commit Graph

1228 Commits

Author SHA1 Message Date
Drew Jaynes adffdab161 Tests: Introduce `WP_UnitTestCase::reset_permalinks()`, an attempt to DRY up logic for resetting and restoring default permalinks on `setUp()` and `tearDown()`.
See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34802 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 17:14:12 +00:00
Sergey Biryukov 4fc732d804 Add missing unit tests from [34799].
Props johnbillion.
See #34059.

git-svn-id: https://develop.svn.wordpress.org/trunk@34801 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 15:09:57 +00:00
John Blackbourn 48300f62b3 Introduce support for array format field names in `WP_Widget::get_field_name()` and `WP_Widget::get_field_id()`.
Fixes #12133
Props ch1902, welcher


git-svn-id: https://develop.svn.wordpress.org/trunk@34780 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 20:23:54 +00:00
Jeremy Felt 464f857316 MS: Introduce `*_network_option` functions.
Introduces `add_network_option()`, `update_network_option()`, `get_network_option()`, and `delete_network_option()`, which use the internals previously found in the `*_site_option()` functions and allow for a network ID to enable cross network storage and retrieval of network options.

* `*_site_option()` functions are now wrappers for `*_network_option()` and will interact with options for the current network in a multisite environment.
* All will continue to fallback to `*_option()` for non-multisite uses.
* Adds basic tests for cross network storage and retrieval.
* Existing tests for `*_site_option()` functions provide coverage for storage and retrieval of current network options.

Props spacedmonkey, DrewAPicture, jeremyfelt.
See #28290.


git-svn-id: https://develop.svn.wordpress.org/trunk@34777 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 18:00:30 +00:00
Boone Gorges 44d021b686 More explicit tests for `image_get_intermediate_size()`.
After [33807], `Tests_Image_Intermediate_Size::test_get_intermediate_sizes_by_array_zero_width()`
was failing intermittently. This failure was due to the use of a random number
for the image height. When the height was sufficiently large - $height >= 202 -
to change the aspect ratio of the cropped image (based on WP's threshold of a
1px difference), the test passed. And when the height was exactly 200, the
medium image size was hit exactly. The failure occurred only with a height of
201, which is close enough to 200 so that WP determined that the aspect ratio
of the potential crop was close enough to match.

The current changeset splits the test into two, in order to demonstrate the
failure.

See #17626. Fixes #34087.

git-svn-id: https://develop.svn.wordpress.org/trunk@34775 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 14:13:15 +00:00
Boone Gorges 991feb7043 Pinking shears in shortcode test file.
git-svn-id: https://develop.svn.wordpress.org/trunk@34774 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 13:50:18 +00:00
Boone Gorges f408407620 Improvements to PCRE benchmarking tests.
* Add test file accidentally omitted from [34761].
* Bail properly from benchmarker when a `preg_last_error()` is found.

Props miqrogroove.
See #34121.

git-svn-id: https://develop.svn.wordpress.org/trunk@34773 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 13:50:12 +00:00
Boone Gorges 19df309491 Fix `preg_match_all()` syntax in PCRE benchmark test util.
In versions of PHP earlier than 5.4, the `$matches` parameter was required.
Excluding it here meant that PCRE benchmarking tests were erroring on older
versions of PHP without cleaning up the PCRE ini settings, causing various
problems on later tests.

Props miqrogroove, dd32, boonebgorges.

And to the cosmic forces that cause bugs like this. The best part of waking up
is diagnosing leakage between automated tests.

See #34121.

git-svn-id: https://develop.svn.wordpress.org/trunk@34772 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 13:50:04 +00:00
Dion Hulse b20695ed9f Skip two `wp_json_encode()` tests when mbstring is unavailable.
git-svn-id: https://develop.svn.wordpress.org/trunk@34771 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 08:54:52 +00:00
Scott Taylor 79dc7efc73 Unit Tests: when `wp_using_ext_object_cache()`, mark some transient tests as skipped.
Props ocean90.
See #31491.


git-svn-id: https://develop.svn.wordpress.org/trunk@34767 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 05:09:03 +00:00
Scott Taylor c6571bcfad Unit Tests: tests that want to flush the cache should use their instance method instead of calling `wp_cache_flush()` - more properties need to be wiped out in between tests.
Props ocean90.
See #31491.


git-svn-id: https://develop.svn.wordpress.org/trunk@34766 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 05:08:13 +00:00
Scott Taylor cae64c5e13 Unit Tests: in `Tests_Cache::test_wp_cache_init()`, when `wp_using_ext_object_cache()`, just check that the global is an instance of `WP_Object_Cache`. External object cache instances of `WP_Object_Cache` will contain resources as props that will always have differing internal IDs, so strict comparison won't work.
See #31491.


git-svn-id: https://develop.svn.wordpress.org/trunk@34765 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 05:05:26 +00:00
Scott Taylor a31e54344c Posts: In `wp_insert_post()`, don't set `post_date` to current time if it can be derived from a passed value for `post_date_gmt`.
Adds unit tests.

Props oso96_2000, kawauso.
Fixes #15946.


git-svn-id: https://develop.svn.wordpress.org/trunk@34762 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 04:35:34 +00:00
Scott Taylor 5a24a0a4f8 Shortcodes/Formatting: Add PCRE Performance Testing
* Move pattern from `wptexturize()` into a separate function.
* Move pattern from `wp_html_split()` into a separate function.
* Beautify code for `wp_html_split()`.
* Remove unnecessary instances of `/s` modifier in patterns that don't use dots.
* Add `tests/phpunit/data/formatting/whole-posts.php` for testing larger strings.
* Add function `benchmark_pcre_backtracking()`.
* Add tests for `wp_html_split()`.
* Add tests for `wptexturize()`.
* Add tests for `get_shortcode_regex()`.

Props miqrogroove.
Fixes #34121.


git-svn-id: https://develop.svn.wordpress.org/trunk@34761 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 04:25:40 +00:00
Jeremy Felt 319818a408 Tests: Clarify site option tests storing and retrieving serialized data.
See #28290.


git-svn-id: https://develop.svn.wordpress.org/trunk@34759 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 02:05:23 +00:00
Jeremy Felt b9e1b4ab7c Tests: Split `test_default_filter()` Site Option test into multiple tests.
See #28290.


git-svn-id: https://develop.svn.wordpress.org/trunk@34758 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 01:55:52 +00:00
Jeremy Felt e261546a61 Tests: Split `test_the_basics()` Site Option test into many tests.
Many assertions in one test are now many tests with one assertion.

See #28290.


git-svn-id: https://develop.svn.wordpress.org/trunk@34757 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 01:32:09 +00:00
Scott Taylor e0b34f44a3 Shortcodes: Fix PCRE performance bugs in `get_shortcode_regexp()` and related to `wptexturize()`, `do_shortcode()`, and `strip_shortcodes()`
Alters unit tests.

Props miqrogroove.
Fixes #33517.


git-svn-id: https://develop.svn.wordpress.org/trunk@34747 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 18:04:13 +00:00
Scott Taylor 1b70f27b04 Shortcodes: prevent registration of invalid shortcode names.
Adds unit tests.

Props miqrogroove.
Fixes #34090.


git-svn-id: https://develop.svn.wordpress.org/trunk@34745 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 17:33:58 +00:00
Boone Gorges 2828042b6e Make sure permastruct is set in `comments_template()` tests.
After [34735].

git-svn-id: https://develop.svn.wordpress.org/trunk@34741 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 12:26:33 +00:00
Gary Pendergast f9f56fb942 WPDB: Allow `null` values in the CRUD functions.
Specifically, `::insert()`, `::replace()`, `::update()`, and `::delete()` can now set a column to `NULL`, or add the `IS NULL` condition to the `WHERE` clause.

This is based on [backpress 279].

Props pento, nbachiyski, sorich87.

Fixes #15158.



git-svn-id: https://develop.svn.wordpress.org/trunk@34737 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 05:36:15 +00:00
Boone Gorges ee2c079ade Ensure that comment permalinks reflect pagination.
After [34561], `wp_list_comments()` no longer passed all of a post's comments
to `Walker_Comments`. As a result, calls to `get_comment_link()` occurring
inside the comment loop had insufficient context to determine the proper
'cpage' value to use when generating comment permalinks. This, in turn, caused
comment permalinks to behave erratically.

The current changeset addresses the problem as follows:

* `get_comment_link()` now accepts a 'cpage' parameter. When present, 'cpage' will be used to build the comment permalink - no automatic calculation will take place.
* When called within the main loop, `wp_list_comments()` calculates the proper 'cpage' value for comments in the loop, and passes it down to `get_comment_link()`.
* `cpage` and `comment-page-x` query vars are generally required in comment permalinks (see #34068), but an exception is made when 'default_comment_page=oldest': the bare post permalink will always be the same as `cpage=1`, so `cpage` is excluded in this case.

Props peterwilsoncc for assiduous spreadsheeting.
Fixes #34073.

git-svn-id: https://develop.svn.wordpress.org/trunk@34735 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 05:12:39 +00:00
Boone Gorges f14dc03ad6 Simplify pagination logic in `comments_template()`.
[34561] "fixed" the problem of newest-first comments showing fewer than
'per_page' comments on the post permalink when the total number of comments
was not divisible by 'per_page'. See #29462. But this fix caused numerous
other problems. First, comment pages reported by `get_page_of_comment()`
(which expects comment pages to be filled oldest-first) were no longer correct.
Second, and more seriously, the new logic caused comments to be shifted
between pages, making their permalinks non-permanent.

The current changeset reverts the changed behavior. In order to preserve the
performance improvements introduced in [34561], an additional query must be
performed when 'default_comments_page=newest' and 'cpage=0' (ie, you're viewing
the post permalink). A nice side effect of this revert is that we no longer
need the hacks required to determine proper comment pagination, introduced in
[34561].

See #8071. See #34073.

git-svn-id: https://develop.svn.wordpress.org/trunk@34729 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 03:10:13 +00:00
Boone Gorges 9dd6f369cf Fix db_version juggling during non-multisite tests.
Continuing with the "code is poetry" theme after [34719], we need to continue
to update the option in the database on non-multisite in this
`wp_insert_term()` test.

See #31130.

git-svn-id: https://develop.svn.wordpress.org/trunk@34720 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-30 13:27:09 +00:00
Boone Gorges 13e28a6d34 Prevent Multisite term tests from hitting database for 'db_version'.
[34718] introduced a 'db_version' check to term meta functions, to ensure that
they don't run when the term meta schema is not yet in place. This call to
`get_option()` causes a database hit during Multisite tests, due to the
presence of the `WP_INSTALLING` constant. See #31130. The extra database
queries are causing cache tests to fail.

In similar cases, we have `markTestSkipped()` when `is_multisite()`. Because
the term meta API is so extensive - term meta caches can be primed anywhere a
`WP_Query` loop is fired up - we implement a more generous workaround in this
case. To prevent `get_option( 'db_version' )` from hitting the database during
multisite unit tests, we use a 'pre_option_' filter.

Heaven help us.

See #34091.

git-svn-id: https://develop.svn.wordpress.org/trunk@34719 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-30 13:08:49 +00:00
Boone Gorges 30a165a1a5 Fix logical errors in some comment pagination tests.
The tests included in [34669] contained a couple of problems:

* Comments were not always created in the expected order, due to the incorrect use of 'comment_date_gmt'.
* 'asc'/'desc' and 'older'/'newer' were confused.
* 'default_comments_page=newest' ('last') didn't properly account for the cpage=1 offset.

The code itself powering this pagination was correct; it's only the tests that
were wrong.

See #8071.

git-svn-id: https://develop.svn.wordpress.org/trunk@34713 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-30 03:06:22 +00:00
Boone Gorges 283c38c022 Improve lazyloading of comment meta in `WP_Query` loops.
Lazy-loading logic is moved to a method on `WP_Query`. This makes it possible
for comment feeds to take advantage of metadata lazyloading, in addition to
comments loaded via `comments_template()`.

This new technique parallels the termmeta lazyloading technique introduced in
[34704].

Fixes #34047.

git-svn-id: https://develop.svn.wordpress.org/trunk@34711 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-30 01:34:54 +00:00
Scott Taylor 427f4fe063 Rewrite: allow `add_rewrite_rule|WP_Rewrite::add_rule()` to accept an associative array for the value of `$redirect` instead of requiring a query string.
Adds unit tests.

Props scribu, DrewAPicture.
Fixes #16840.


git-svn-id: https://develop.svn.wordpress.org/trunk@34708 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-30 01:10:03 +00:00
Boone Gorges e75f2c024f Improve lazyloading of term metadata in `WP_Query` loops.
[34529] introduced lazyloading for the metadata belonging to terms matching
posts in the main `WP_Query`. The current changeset improves this technique
in the following ways:

* Term meta lazyloading is now performed on the results of all `WP_Query` queries, not just the main query.
* Fewer global variable touches and greater encapsulation.
* The logic for looping through posts to identify terms is now only performed once per `WP_Query`.

Props dlh, boonebgorges.
See #34047.

git-svn-id: https://develop.svn.wordpress.org/trunk@34704 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 21:59:44 +00:00
John Blackbourn 601ace8b25 `force_ssl_login()` has been functionally identical to `force_ssl_admin()` since 4.0 (#10267), so its test assertions can be removed as the function has been deprecated in [34700]. The remaining assertions suitably cover `force_ssl_admin()`.
See #34011


git-svn-id: https://develop.svn.wordpress.org/trunk@34703 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 21:43:04 +00:00
Drew Jaynes c226bff80b Tests: Add two tests for the current behavior of the 'hierarchical' and 'child_of' arguments in `get_pages()`.
See #18701.


git-svn-id: https://develop.svn.wordpress.org/trunk@34699 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 21:27:03 +00:00
Drew Jaynes 49f4196f12 Tests: Add two tests for the current 'hierarchical' argument behavior in `get_pages()`.
See #18701.


git-svn-id: https://develop.svn.wordpress.org/trunk@34698 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 20:49:32 +00:00
Boone Gorges 49063d8e14 `WP_Query` should not ignore an offset of `0`.
Props mazurstas.
Fixes #34060.

git-svn-id: https://develop.svn.wordpress.org/trunk@34697 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 19:36:16 +00:00
Boone Gorges 3b7187eade Fix 'exclude_tree' in `wp_list_categories()`.
The 'exclude_tree' parameter must be compatible with 'hierarchical';
previously, 'hierarchical' canceled it out. This changeset also makes it so
that 'exclude_tree' is compatible with 'exclude'. When both are passed, and
'hierarchical' is true, the descendant trees of terms in both parameters will
be excluded from matched terms.

Props tott, webord, MikeHansenMe.
Fixes #12981.

git-svn-id: https://develop.svn.wordpress.org/trunk@34696 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 19:11:12 +00:00
Aaron Jorbin f765605336 Cleanup image size in unit tests
This helps prevent test leakage that can cause Tests_Media::test_add_image_size to break.

See #33968



git-svn-id: https://develop.svn.wordpress.org/trunk@34694 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 17:47:24 +00:00
Gary Pendergast ce14a63214 Permalinks: Add pretty permalinks for unattached attachments.
Previously, unattached attachments would have unsightly `/?attachment_id=1` URLs. As we've moved away from attachments being specifically attached to posts, instead being Media items, this has made the unattached URLs a more common occurrence.

We can breath easy once more, knowing that the world is a little bit safer from the horror of unnecessarily ugly URLs.

Props SergeyBiryukov, wonderboymusic, pento.

Fixes #1914.



git-svn-id: https://develop.svn.wordpress.org/trunk@34690 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 09:41:14 +00:00
Drew Jaynes f270e7a03e Tests: Relocate tests for general-template.php to a more logically-placed (and named) file, tests/general/template.php.
See #34070.


git-svn-id: https://develop.svn.wordpress.org/trunk@34688 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 05:51:14 +00:00
Drew Jaynes 6f6f62b6e5 Tests: Consolidate author-template tests into a single, more logically-placed file, tests/user/author.php.
See #34070.


git-svn-id: https://develop.svn.wordpress.org/trunk@34687 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 05:37:00 +00:00
Scott Taylor 1ac3ba0828 Allow `wp_get_archives()` to accept `post_type` as an arg.
Adds unit test.

Fixes #21596.


git-svn-id: https://develop.svn.wordpress.org/trunk@34686 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 05:10:10 +00:00
Gary Pendergast 070b65dcfc Rewrite: Redirect attachment URLs when their slug changes.
Using the same logic that we use to redirect posts when their slug changes, we can provide the same functionality for attachments. Attachment pages are posts, too.

Props swissspdy.

Fixes #34043.



git-svn-id: https://develop.svn.wordpress.org/trunk@34685 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 04:57:02 +00:00
Scott Taylor 9bffa403dd XML-RPC: add a unit test for `mw.editPost`.
See #16980.


git-svn-id: https://develop.svn.wordpress.org/trunk@34682 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 04:27:57 +00:00
Scott Taylor 948ab018d2 XML-RPC: calculate the proper offset for GMT in `wp.newPost`, `mw.newPost`, and `mw.editPost` when `post_date` is set, `wp.editComment` when `comment_date` is set. `post|comment_date` is assumed to be GMT. This is only true if the timezone string for the site matches GMT.
Adds unit tests for each.

Props smerriman, justdaiv, wonderboymusic.
Fixes #30429.


git-svn-id: https://develop.svn.wordpress.org/trunk@34681 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 04:04:16 +00:00
Boone Gorges 16e0cc873b Add unit tests for `post_exists()`.
Props MikeHansenMe.
See #34012.

git-svn-id: https://develop.svn.wordpress.org/trunk@34680 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 04:02:00 +00:00
Boone Gorges 36af857315 Don't require explicit taxonomy when getting terms by term_taxonomy_id.
Props wonderboymusic.
Fixes #30620.

git-svn-id: https://develop.svn.wordpress.org/trunk@34679 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 03:51:11 +00:00
Drew Jaynes 58d7f89bf7 Tests: Flush rewrite rules between tests in an attempt to avoid permalinks pollution in `Tests_Author_Template`.
See #30355.


git-svn-id: https://develop.svn.wordpress.org/trunk@34678 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 02:18:55 +00:00
Drew Jaynes 3edc3b46f2 Introduce `get_the_author_posts_link()`, which returns the HTML link to the author page for the current post's author.
`the_author_posts_link()` has in-turn been converted into a wrapper, with most of its logic moved to the new function.

Adds tests for the new function.

Props chipbennett, zrothauser, wonderboymusic, DrewAPicture.
Fixes #30355.


git-svn-id: https://develop.svn.wordpress.org/trunk@34677 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 01:48:47 +00:00
John Blackbourn f0200152be Revert r34674 due to failures on PHP < 5.4.
See #16859


git-svn-id: https://develop.svn.wordpress.org/trunk@34675 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 01:00:17 +00:00
John Blackbourn 2183725c54 Avoid stripping square brackets from URLs, and instead correctly encode them.
Square brackets must be encoded in the path, path parameters, query parameters, and fragment, but must not be encoded in anything up to the domain and port.

Adds a bunch of tests, including square brackets in query parameters, IPv6 URLs, and several other permutations.

See #16859


git-svn-id: https://develop.svn.wordpress.org/trunk@34674 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 00:40:30 +00:00
Helen Hou-Sandi 94f596278c Sample permalink: Buttons still need the `.button` class.
Also fixes unit tests post-[34670]. The test methods have been slightly renamed because it is no longer a button. Hopefully this name will be more future-proof.

see #18306.


git-svn-id: https://develop.svn.wordpress.org/trunk@34671 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 22:06:15 +00:00
Boone Gorges f261d3ac8a Fix comment_order for single page comment threads.
The old comment pagination logic had a separate block for comment threads that
appeared on a single page. After the refactoring in [34561], all comment
pagination logic is unified.

This change ensures that 'comment_order' is respected in all scenarios.

Fixes #8071.

git-svn-id: https://develop.svn.wordpress.org/trunk@34669 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 19:29:22 +00:00