Commit Graph

1384 Commits

Author SHA1 Message Date
Weston Ruter
42687da29c Widgets: Modify unit test assertion to be compatible with widget_nav_menu option being filtered by plugin to return ArrayIterator.
Modifies assertion added in [35100].

See #26876.
See #32474.


git-svn-id: https://develop.svn.wordpress.org/trunk@35272 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-19 21:26:24 +00:00
Drew Jaynes
f03562b364 Tests: Add some more test coverage for get_term_field().
See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35270 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-19 03:28:49 +00:00
Boone Gorges
990eebf373 Bust object term cache in wp_remove_object_terms().
Props tszming.
Fixes #34338.

git-svn-id: https://develop.svn.wordpress.org/trunk@35268 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-19 01:52:22 +00:00
John Blackbourn
39c6a77617 Some cleanup that was missed in [35259].
See #33728, #24853


git-svn-id: https://develop.svn.wordpress.org/trunk@35260 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-18 06:25:25 +00:00
John Blackbourn
219b56a6a4 Some rewrite endpoint tests in preparation for new endpoint masks. More to come.
See #33728, #24853


git-svn-id: https://develop.svn.wordpress.org/trunk@35259 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-18 06:23:48 +00:00
John Blackbourn
a314c6c234 Preserve the public and private query var properties on the global WP instance when using WP_UnitTestCase::go_to(). These properties apply to the application state, not the current request.
See #34346


git-svn-id: https://develop.svn.wordpress.org/trunk@35258 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-18 05:00:40 +00:00
John Blackbourn
9fbff7f63a Add is_embed() to WP_UnitTestCase::assertQueryTrue() and update the relevant embed tests.
See #32522


git-svn-id: https://develop.svn.wordpress.org/trunk@35257 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-18 04:50:15 +00:00
John Blackbourn
6845b3cd4a Move the test_is_home_should_be_false_when_visiting_custom_endpoint_without_a_registered_query_var_and_page_on_front_is_set() test into a more appropriate place.
See #25143


git-svn-id: https://develop.svn.wordpress.org/trunk@35256 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-18 01:34:29 +00:00
John Blackbourn
ab43e7362d Correct a test after r35253.
See #34272


git-svn-id: https://develop.svn.wordpress.org/trunk@35255 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-18 00:55:16 +00:00
John Blackbourn
d5b31e6ba2 Introduce map_deep(), a utility function that recursively maps a callable function to every item in an array or object. Works like array_walk_recursive() but works with objects too.
Updates `rawurlencode_deep()`, `urlencode_deep()`, and `stripslashes_deep()` to use `map_deep()`. Introduces `urldecode_deep()` for completeness.

Props wpmuguru, nbachiyski, boonebgorges, MikeHansenMe, chriscct7, realloc, johnbillion
Fixes #22300


git-svn-id: https://develop.svn.wordpress.org/trunk@35252 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 23:25:21 +00:00
Scott Taylor
768958f7a0 Unit Tests: better fixtures for Tests_Meta_Slashes and Tests_WP_Customize_Section.
See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35249 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 21:28:43 +00:00
Scott Taylor
80b732819b Unit Tests: better fixtures for Tests_User_WpSetCurrentUser.
See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35248 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 21:18:38 +00:00
Scott Taylor
721d4c5a77 Unit Tests: better fixtures for Tests_User.
See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35247 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 21:14:28 +00:00
Scott Taylor
c173dc5595 Unit Tests: better fixtures for Tests_AdminBar. Don't force-delete some posts: some filter callbacks are no-ops on Multisite if the post is vanquished.
See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35246 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 20:48:33 +00:00
Scott Taylor
8506f48d6b Unit Tests: better fixtures for Tests_Admin_Includes_Post.
See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35245 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 19:47:07 +00:00
Scott Taylor
613e88fe86 Unit Tests: WP_UnitTest_Generator_Sequence needs a static incrementer - otherwise, it assumes every test class is a reset, which it no longer is (it is now static).
While we're at it, remove unnecessary `tearDown()` code.

See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35244 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 19:24:20 +00:00
Scott Taylor
ae226d66b6 Unit Tests: after [35242], declare some missing instance props on individual test classes.
See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35243 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 18:29:32 +00:00
Scott Taylor
b757b37551 Unit Tests: after [35225], make factory a method/getter on WP_UnitTestCase and add magic methods for BC for every plugin that is extending WP_UnitTestCase and accessing the $factory instance prop.
Props nerrad, wonderboymusic.
See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35242 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 18:02:16 +00:00
Weston Ruter
0e81f51cac Customizer: Add unit test for WP_Customize_Widgets::is_panel_active().
See #33052.


git-svn-id: https://develop.svn.wordpress.org/trunk@35236 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 04:43:27 +00:00
Sergey Biryukov
9b591d6b09 Embeds: Rename files, functions, and hooks added in [34903] to make it more clear what is oEmbed-specific and what isn't.
See https://core.trac.wordpress.org/ticket/34272#comment:7 for full list of renamed functions and hooks.

Props swissspidy.
Fixes #34272.

git-svn-id: https://develop.svn.wordpress.org/trunk@35235 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 01:20:19 +00:00
Boone Gorges
f22ba848df Return null from get_term() on taxonomy mismatch.
[34997] caused `get_term()` to return an error object in the case when
`$taxonomy` did not match the taxonomy of the located term. This was an
inadvertant change from the previous behavior, when `get_term()` would return
null in these cases.

Props dlh.
See #14162. Fixes #34332.

git-svn-id: https://develop.svn.wordpress.org/trunk@35227 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-16 21:41:51 +00:00
Scott Taylor
61edcd5021 Unit Tests: PHP 5.2, I Hate You and You Are Bringing Me Down.
#YOLOFriday

See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35226 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-16 21:14:52 +00:00
Scott Taylor
e70ebea219 Unit Tests: one $factory to rule them all, and it shall be static.
Using more than one instance of `WP_UnitTest_Factory` causes all kinds of craziness, due to out-of-sync internal generator sequences. Since we want to use `setUpBeforeClass`, we were creating ad hoc instances. To avoid that, we were injecting one `static` instance via Dependency Injection in `wpSetUpBeforeClass`. All tests should really use the `static` instance, so we will remove the instance prop `$factory`.

Replace `$this->factory` with `self::$factory` over 2000 times.
Rewrite all of the tests that were hard-coding dynamic values. 

#YOLOFriday



git-svn-id: https://develop.svn.wordpress.org/trunk@35225 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-16 21:04:12 +00:00
Scott Taylor
84272ff8cd Unit Tests: since [32953], we can just use self::delete_user() instead of using if logic for Multisite.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35224 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-16 19:51:32 +00:00
Scott Taylor
2845280ffd Unit Tests: add SpeedTrapListener to phpunit/includes and add the config node to phpunit.xml.dist.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35214 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-16 00:27:28 +00:00
Dominik Schilling (ocean90)
c6e2e6c1b5 Tests: Remove the @runTestsInSeparateProcesses annotation for Ajax tests.
They were added 3 years ago in [846/tests] because tests weren't excluded from the normal runs.

Reverts [35209] because it doesn't work with Xdebug.
`Tests_Ajax_Response::test_response_charset_in_header` is the only test which needs to run in a separate process, see [975/tests].

See #31491.

git-svn-id: https://develop.svn.wordpress.org/trunk@35211 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 21:30:52 +00:00
Dominik Schilling (ocean90)
666d07352e Tests: Don't preserve the global state for Ajax tests when using an external object cache.
Most of the Ajax tests are running in a separate PHP process, and thus PHPUnit attempts to preserve the global state from the parent process by serializing all globals. But this doesn't work for external object caches so we have to disable this "feature".

See #31491.

git-svn-id: https://develop.svn.wordpress.org/trunk@35209 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 20:34:08 +00:00
Boone Gorges
1b6a8019c3 Fix incorrect variable name introduced in [35197].
See #30017, #33968.

git-svn-id: https://develop.svn.wordpress.org/trunk@35206 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 18:47:11 +00:00
Scott Taylor
43d18b25b0 Unit Tests: add/upgrade the fixtures in Tests_User_Query.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35197 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 07:28:40 +00:00
Scott Taylor
32719bf251 Unit Tests: create fewer terms in Tests_Term_getTerms::test_get_terms_parent_zero()
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35196 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 06:52:19 +00:00
Sergey Biryukov
65390cd9cf In WP::parse_request() and url_to_postid(), if a post slug clashes with a trashed page, return the post instead of the page.
Props kovshenin, SergeyBiryukov, igmoweb.
Fixes #21970.

git-svn-id: https://develop.svn.wordpress.org/trunk@35195 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 06:48:22 +00:00
Scott Taylor
0cf7a91d3a Unit Tests: upgrade the fixtures in Tests_Post_Thumbnail_Template.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35194 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 06:39:43 +00:00
Scott Taylor
a65f390db6 Unit Tests: upgrade the fixtures in Tests_Post_Revisions.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35193 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 06:31:16 +00:00
Scott Taylor
5fc726c222 Unit Tests: in Tests_Comment_Query::test_get_comments_for_post(), create fewer comments (5, instead of 10).
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35192 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 05:56:47 +00:00
Scott Taylor
d424f690d2 Unit Tests: after [35186], "upgrade" the Canonical fixtures.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35191 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 05:50:40 +00:00
Sergey Biryukov
e675e2ccf0 Users: Add 'illegal_user_logins' filter to allow certain usernames to be blacklisted.
Props danielbachhuber, chriscct7, crazycoolcam, SergeyBiryukov.
Fixes #27317.

git-svn-id: https://develop.svn.wordpress.org/trunk@35189 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 05:42:05 +00:00
Scott Taylor
742082c042 Unit Tests: create more fixtures for Tests_User. When using a factory to create ad hoc users, use the inherited static prop $static_factory instead of the instance prop, $factory. If 2 factories are used out of sync, the generator sequences diverge and dupes can be created, causing an untold number of unforeseen errors. Yay.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35188 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 05:29:40 +00:00
Scott Taylor
16d98ebf73 Unit Tests: implement setUpBeforeClass() and tearDownAfterClass() on WP_UnitTestCase. Use late static binding (plus a gross fallback for PHP 5.2) to check if wpSetUpBeforeClass() or wpTearDownAfterClass() exist on the called class, and then call it and pass a static WP_UnitTest_Factory instance via Dependency Injection, if it exists.
This makes it way easier to add fixtures, and tear them down, without needing to instantiate `WP_UnitTest_Factory` in every class - removes the need to call `commit_transaction()` in each individual class.

See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35186 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 04:43:37 +00:00
Scott Taylor
e1a09eff54 Unit Tests: in Tests_Term, create fixtures for posts.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35185 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 03:47:36 +00:00
Scott Taylor
8cc22363db Unit Tests: in Tests_Post, create fixtures for users.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35183 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 03:30:09 +00:00
Scott Taylor
3cc9adb890 Unit Tests: in Tests_Media::test_wp_get_attachment_image_srcset_array_no_width(), just toggle metadata, instead of creating a new attachment. Shaves 75ms off the test.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35181 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 02:54:20 +00:00
Scott Taylor
011c1a2e2c Unit Tests: make a fixture in Tests_Media to represent the large image, instead of creating it 10 times.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35179 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 01:42:27 +00:00
Scott Taylor
75e4de9671 Unit Tests: move some oEmbed tests that can trigger HTTP calls to Tests_External_HTTP_OEmbed.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35178 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 01:28:05 +00:00
Scott Taylor
fc7efaf9b1 Unit Tests: Tests_Canonical doesn't need to call wp_set_current_user() or implement tearDown because its grandparent calls wp_set_current_user( 0 ) in tearDown().
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35177 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 01:17:22 +00:00
Scott Taylor
a270d619ad Unit Tests: Tests_Comment needs a tearDownAfterClass impl to avoid spillage.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35176 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 01:05:50 +00:00
Scott Taylor
9d5c7055e6 Unit Tests: Tests_Auth needs a tearDownAfterClass impl to avoid spillage.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35175 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 01:03:16 +00:00
Scott Taylor
5fc04e0e26 Unit Tests: call commit_transaction() in Tests_Auth set up.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35174 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 00:48:22 +00:00
Scott Taylor
5d91776307 Unit Tests: reuse fixtures in Tests_Comment.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35173 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 00:38:26 +00:00
Scott Taylor
6f80581b80 Unit Tests: move ->test_readme() out of Tests_Basic and into Tests_External_HTTP_Basic in tests/external-http/.
I intend to move other `wp_remote_get()` tests into similar classes.

See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35172 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 00:22:50 +00:00
Scott Taylor
c1b2a034d3 Unit Tests: wrestle performance out of Tests_Auth by cloning the same user for a majority of the tests.
See #30017, #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@35171 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-15 00:10:45 +00:00
Boone Gorges
734d3794ac Fix incorrect variable names from [35164].
Cool story - the tests appeared to pass with the typos.

See #30017, #33968.

git-svn-id: https://develop.svn.wordpress.org/trunk@35165 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-14 21:59:14 +00:00
Boone Gorges
8c7dc25bed Share fixtures in Tests_Admin_includesListTable tests.
See #30017, #33968.

git-svn-id: https://develop.svn.wordpress.org/trunk@35164 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-14 21:40:44 +00:00
Boone Gorges
9f7bfa9805 Share fixtures in Tests_Get_Archives.
See #30017, #33968.

git-svn-id: https://develop.svn.wordpress.org/trunk@35163 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-14 21:29:59 +00:00
Boone Gorges
6c28fe3853 Create fewer fixtures in some tests.
See #30017, #33968.

git-svn-id: https://develop.svn.wordpress.org/trunk@35162 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-14 21:23:03 +00:00
Boone Gorges
6c674cfe20 Create fewer fixtures in XML-RPC getComments tests.
See #30017, #33968.

git-svn-id: https://develop.svn.wordpress.org/trunk@35154 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-14 14:38:30 +00:00
Dominik Schilling (ocean90)
5fc2385b1a Improve [35146] to only skip pluggable function signature tests for wp-includes/cache.php when an external object cache is in use.
See #31491, #33867.

git-svn-id: https://develop.svn.wordpress.org/trunk@35148 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 20:44:16 +00:00
John Blackbourn
b2fd51c648 Reinstate wp_cache_get() into the pluggable function tests. The signature tests are now skipped if an external object cache is in use.
See #31491


git-svn-id: https://develop.svn.wordpress.org/trunk@35147 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 19:32:27 +00:00
John Blackbourn
8c1781953c Skip the pluggable function signature tests when an external object cache is in use.
See #31491


git-svn-id: https://develop.svn.wordpress.org/trunk@35146 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 19:30:34 +00:00
John Blackbourn
9d23a7ff96 Remove wp_cache_reset() from the pluggable functions signature tests, as the function is deprecated and no longer used.
See #31491, #33867


git-svn-id: https://develop.svn.wordpress.org/trunk@35145 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 19:19:04 +00:00
Scott Taylor
16b02b6768 KSES: have you ever heard of the <bdo> HTML tag? Same. http://www.w3schools.com/tags/tag_bdo.asp
Adds unit test.

Props iandunn.
Fixes #34063.


git-svn-id: https://develop.svn.wordpress.org/trunk@35141 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 17:17:13 +00:00
Boone Gorges
c067ef07ec Create fewer fixtures in some XML-RPC tests.
See #30017, #33968.

git-svn-id: https://develop.svn.wordpress.org/trunk@35137 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 15:31:26 +00:00
Boone Gorges
e3f8b888ad In WP_UnitTestCase, only flush rewrite rules when they're set.
See [34810]. See #33968.

git-svn-id: https://develop.svn.wordpress.org/trunk@35136 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 15:21:20 +00:00
Scott Taylor
c3d9dffae6 After [35122], update test_wp_unique_filename() to reflect the change.
See #16226.


git-svn-id: https://develop.svn.wordpress.org/trunk@35124 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 03:41:11 +00:00
Boone Gorges
0091665f1c Correct expected counts in WP_User_Query 'number' test.
The `create_many()` number should be padded by just one, to account for the
user created by the test suite. Introduced in [35114].

We also don't have to create so many fixtures to run this test.

See #28631.

git-svn-id: https://develop.svn.wordpress.org/trunk@35123 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 03:25:42 +00:00
Scott Taylor
a6a0045460 Fotmatting: in sanitize_file_name(), escape % when uploads contain them, otherwise attachment URLs will unescape the char and break.
Adds unit tests.

Props mordauk, simonwheatley, dd32, solarissmoke.
Fixes #16226.


git-svn-id: https://develop.svn.wordpress.org/trunk@35122 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 03:21:13 +00:00
Boone Gorges
f9094e546a In get_terms(), don't store WP_Term objects in cache.
Fixes #34282.

git-svn-id: https://develop.svn.wordpress.org/trunk@35117 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 02:57:21 +00:00
Scott Taylor
34cb01e2f1 Users: when passing a WP_User instance to wp_update_user(), ensure that the user password is not accidentally double-hashed. This is terrifying.
Adds unit tests.

Props tbcorr, salcode.
Fixes #28435.


git-svn-id: https://develop.svn.wordpress.org/trunk@35116 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 02:47:09 +00:00
Scott Taylor
4c0b89553a Users: allow -1 (no limit, use with extreme caution on large sites) as the value for number in WP_User_Query - similar to posts_per_page => -1 in WP_Query.
Adds unit tests.

Props mordauk, jesin, nofearinc.
Fixes #28631.


git-svn-id: https://develop.svn.wordpress.org/trunk@35114 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 02:39:05 +00:00
Scott Taylor
455392c531 Widgets: after [35106], ensure that the widget required by the unit test is registered.
See #19450.


git-svn-id: https://develop.svn.wordpress.org/trunk@35113 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 02:35:47 +00:00
Boone Gorges
e31a0390b1 In term meta lazy-loading tests, force WP_Query to cache results.
By default, `WP_Query` will not cache query results when using a persistent
object cache. The lazyload tests, however, depend on the cache being set during
each `WP_Query`, because the object cache is cleared between tests.

See #31491.

git-svn-id: https://develop.svn.wordpress.org/trunk@35112 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 02:35:36 +00:00
Boone Gorges
20225eb62a In cache tests, determine cache class name dynamically.
Some cache backends may use a class name other than `WP_Object_Cache` for their
cache drop-in. For example, certain versions of the APC Object Cache plugin
have a shim called `APC_Object_Cache`.

See #31491.

git-svn-id: https://develop.svn.wordpress.org/trunk@35108 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 02:06:19 +00:00
Scott Taylor
65c8adc252 Widgets: When using the_widget(), the $before_widget argument only receives the widget class if using the default sidebar arguments. Run sprintf after parsing the args to fix this.
Adds unit test.

Props coffee2code.
Fixes #19450.


git-svn-id: https://develop.svn.wordpress.org/trunk@35106 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 01:48:41 +00:00
Boone Gorges
9f551a4630 Don't match partial roles in WP_User_Query.
Because 'role=ocean90' shouldn't match 'role=bocean901'.

Props bocean901, ocean90.
Fixes #22212.

git-svn-id: https://develop.svn.wordpress.org/trunk@35101 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 01:31:53 +00:00
Scott Taylor
d936110f7c Widgets: when getting settings, and none exist, set them to empty to avoid extraneous database queries on subsequent requests.
Adds unit tests.

Props kovshenin, MikeHansenMe, dlh.
Fixes #26876.


git-svn-id: https://develop.svn.wordpress.org/trunk@35100 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-13 01:12:12 +00:00
Sergey Biryukov
e85d9f1312 Correct the post_date format in WP_Date_Query tests.
It should be `'Y-m-d H:i:s'` in order to match the regex in `get_gmt_from_date()` if `'timezone_string'` option is not set.

Props pbearne.
Fixes #34277.

git-svn-id: https://develop.svn.wordpress.org/trunk@35091 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-12 23:39:50 +00:00
Boone Gorges
ed4eee668e Don't cache WP_Term objects in wp_get_object_cache().
The data stored in the cache should be raw database query results, not
`WP_Term` objects (which may be modified by plugins, and may contain additional
properties that shouldn't be cached).

If term relationships caches were handled in `wp_get_object_terms()` - where
a database query takes place - it would be straightforward to cache raw data.
See #34239. Since, in fact, `get_the_terms()` caches the value it gets from
`wp_get_object_terms()`, we need a technique that allows us to get raw data
from a `WP_Term` object. Mirroring `WP_User`, we introduce a `data` property
on term objects, which `get_the_terms()` uses to fetch cacheable term info.

Fixes #34262.

git-svn-id: https://develop.svn.wordpress.org/trunk@35032 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-12 15:12:29 +00:00
Boone Gorges
e8b0d11989 Fix incorrect setup in 'tag' query var test.
The test, introduced in [33724], was intended to demonstrate the behavior of
`example.com?tag=foo` routing. But an error in the test setup meant that a
URL-encoded tag object was being set as the value of 'tag'. Due to a quirk in
the way that `parse_request()` parses query vars, an object value for 'tag'
would inadvertently produce correct results in certain cases. But it's not a
usage we actively support, and it's not what was meant to be tested.

See #33532, #34262.

git-svn-id: https://develop.svn.wordpress.org/trunk@35030 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-12 15:03:43 +00:00
Boone Gorges
8847a58443 Don't require a $taxonomy to be specified in get_term_field().
After [34997], the `$taxonomy` parameter of `get_term()` is optional. This
changeset brings `get_term_field()` in line with the new usage.

Adds unit tests for `get_term_field()`.

Props DrewAPicture.
See #34245.

git-svn-id: https://develop.svn.wordpress.org/trunk@35028 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-12 04:13:25 +00:00
Jeremy Felt
3ee40d6652 MS: Reject truthy, non-numeric network ids in _network_option().
A valid `$network_id` or `null`/`false` is expected as the first parameter for `_network_option()`. If something other than that is passed, we immediately return `false` rather than attempting to guess what network was intended.

See #28290.


git-svn-id: https://develop.svn.wordpress.org/trunk@35025 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-11 23:29:55 +00:00
Jeremy Felt
55122c1538 MS: Adjust _network_option() parameter order, $network_id is first.
This better aligns with expectations and matches the structure used by `_blog_option()`. The `_site_option()` functions remain as an appropriate method for working with the current network.

See #28290.


git-svn-id: https://develop.svn.wordpress.org/trunk@35024 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-11 22:43:59 +00:00
Jeremy Felt
d5e572f992 MS: Handle the possibility of 0 when checking a user's upload quota.
Upload space of 0 is now more possible via r35016 and should be respected rather than modified to a default of 10MB.

Fixes #34037.


git-svn-id: https://develop.svn.wordpress.org/trunk@35017 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-10 23:17:01 +00:00
Jeremy Felt
d9edf86faf MS: Allow for a blog_upload_space setting of 0 to restrict uploads.
Previously, an value matching `empty()` would have been bypassed in favor of the default setting for 100MB.

Related #19538, r19639, r19652, where we saw the bug, fixed the bug, and then unfixed the bug so that it was not a surprise in a point release.

See #34037.


git-svn-id: https://develop.svn.wordpress.org/trunk@35016 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-10 23:14:11 +00:00
Weston Ruter
e158ff27de Customizer: Fix scalability performance problem for previewing multidimensional settings.
As the number of multidimensional settings (serialized options and theme mods) increase for a given ID base (e.g. a widget of a certain type), the number of calls to the `multidimensional` methods on `WP_Customize_Setting` increase exponentially, and the time for the preview to refresh grows in time exponentially as well.

To improve performance, this change reduces the number of filters needed to preview the settings off of a multidimensional root from N to 1. This improves performance from `O(n^2)` to `O(n)`, but the linear increase is so low that the performance is essentially `O(1)` in comparison. This is achieved by introducing the concept of an "aggregated multidimensional" setting, where the root value of the multidimensional serialized setting value gets cached in a static array variable shared across all settings.

Also improves performance by only adding preview filters if there is actually a need to do so: there is no need to add a filter if there is an initial value and if there is no posted value for a given setting (if it is not dirty).

Fixes #32103.


git-svn-id: https://develop.svn.wordpress.org/trunk@35007 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-10 09:05:04 +00:00
Boone Gorges
d6748bd2cb Return WP_Post objects from wp_get_object_terms().
A side effect of this change is that terms stored in the cache no longer have
an `object_id` associated with them. Previously, `object_id` had always been
cached when the term cache was populated via `wp_get_object_terms()`, a
strategy that was mostly harmless but still incorrect.

See #14162.

git-svn-id: https://develop.svn.wordpress.org/trunk@34999 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-10 03:38:41 +00:00
Boone Gorges
797ddb60ba Return WP_Term objects from get_terms().
Props boonebgorges, flixos90, DrewAPicture.
See #14162.

git-svn-id: https://develop.svn.wordpress.org/trunk@34998 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-10 02:12:40 +00:00
Boone Gorges
134a7af0fc Introduce WP_Term.
`get_term()` now returns a `WP_Term` object, instead of a `stdClass` object.
Cache support and sanitization filters for individual terms are now more
centralized. For example, `get_term_by()` is able to cast results of its query
to a `WP_Term` object by passing it through `get_term()`.

The `$taxonomy` parameter for `get_term()` is now optional, as terms ought to
be unique to a taxonomy (ie, shared terms no longer exist). In cases where
`get_term()` detects that the term matching the specified term_id is from the
wrong taxonomy, it checks to see if you've requested a shared term, and if so,
it splits the term. This is used only for fallback purposes.

The elimination of shared terms allows the caching strategy for terms to be
simplified. Individual terms are now cached in a single 'terms' bucket.

Props flixos90, boonebgorges, scribu, dipesh.kakadiya.
See #14162.

git-svn-id: https://develop.svn.wordpress.org/trunk@34997 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-10 01:58:37 +00:00
Boone Gorges
dc2b7c634d Ensure that WP_Date_Query accepts a value of 0 for 'hour'.
Props jim912.
Fixes #34228.

git-svn-id: https://develop.svn.wordpress.org/trunk@34989 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-09 16:32:59 +00:00
Drew Jaynes
6350d90339 Tests: Add basic DocBlocks for four helper methods in general/template.php used to assist testing the Site Icon feature.
All four helpers were introduced in the feature merge for 4.3.

See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34983 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-09 04:34:29 +00:00
John Blackbourn
bc043c51e8 Introduce the ability to filter the Users admin listing screen by users with no role, if such users exist.
Fixes #22993
Props spmlucas, johnbillion


git-svn-id: https://develop.svn.wordpress.org/trunk@34965 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 22:06:46 +00:00
Boone Gorges
fa1e061dac WP_User_Query role improvement redux.
It's back, and it's better than ever: an overhaul of role-related arguments
in `WP_User_Query`. This updated version of the previously-reverted [34875]
includes support for the use of `$blog_id` without specifying a `$role`, for
a 99.7% reduced chance of breaking wordpress.org and other large sites.

Props boonebgorges, swissspidy.
Fixes #22212.

git-svn-id: https://develop.svn.wordpress.org/trunk@34959 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 21:27:04 +00:00
Drew Jaynes
a6e9d49467 Administration: Add the ability to pass an array of screen IDs to add_meta_box() and remove_meta_box().
The `$screen` parameter in both functions can now accept a single screen ID, `WP_Screen` object, or an array of screen IDs.

Adds tests.

Props coffee2code, iamfriendly, madalinungureanu, mordauk, igmoweb, meloniq, DrewAPicture.
See #15000.


git-svn-id: https://develop.svn.wordpress.org/trunk@34951 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 19:06:32 +00:00
Konstantin Obenland
7e923cc0fe Template: Add fallback for empty containers.
Since [14031] the container can be omitted in `wp_nav_menu()`. It can not
however in `wp_page_menu()`, which creates a conflict if it is set as
the fallback, Let's make sure there is always a valid container tag.

Fixes #33974.



git-svn-id: https://develop.svn.wordpress.org/trunk@34950 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 18:26:13 +00:00
Boone Gorges
a1389117b2 Allow a null id to do a name lookup in wp_set_current_user().
Previously, the `name` fallback was failing in the case where the current user
was 0, due to a loose comparison between 0 (the current user) and `null` (the
value that is used to trigger the `name` fallback).

Props bobbingwide.
Fixes #20845.

git-svn-id: https://develop.svn.wordpress.org/trunk@34947 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 17:28:34 +00:00
Boone Gorges
5c496e841a Add tests for current behavior of wp_set_current_user().
See #20845.

git-svn-id: https://develop.svn.wordpress.org/trunk@34945 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 17:19:00 +00:00
Boone Gorges
9c9cdf28ca Allow excluded keywords when searching posts.
Pass a keyword with a leading hyphen to exclude posts containing that keyword.
For example, 'taco -onions' will return posts that contain the word 'taco' but
do not contain the word 'onions'.

Props akibjorklund.
Fixes #33988.

git-svn-id: https://develop.svn.wordpress.org/trunk@34934 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 03:17:22 +00:00
John Blackbourn
ba7dc01639 Abstract the shortcode attribute parsing regex into its own function, update the JavaScript counterpart, and introduce a test to ensure they do not diverge again.
Fixes #34191
Props miqrogroove, johnbillion


git-svn-id: https://develop.svn.wordpress.org/trunk@34933 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 03:11:59 +00:00
Ryan McCue
b39211475d REST API: Introduce baby API to the world.
Baby API was born at 2.8KLOC on October 8th at 2:30 UTC. API has lots
of growing to do, so wish it the best of luck.

Thanks to everyone who helped along the way:

Props rmccue, rachelbaker, danielbachhuber, joehoyle, drewapicture,
adamsilverstein, netweb, tlovett1, shelob9, kadamwhite, pento,
westonruter, nikv, tobych, redsweater, alecuf, pollyplummer, hurtige,
bpetty, oso96_2000, ericlewis, wonderboymusic, joshkadis, mordauk,
jdgrimes, johnbillion, jeremyfelt, thiago-negri, jdolan, pkevan,
iseulde, thenbrent, maxcutler, kwight, markoheijnen, phh, natewr,
jjeaton, shprink, mattheu, quasel, jmusal, codebykat, hubdotcom,
tapsboy, QWp6t, pushred, jaredcobb, justinsainton, japh, matrixik,
jorbin, frozzare, codfish, michael-arestad, kellbot, ironpaperweight,
simonlampen, alisspers, eliorivero, davidbhayes, JohnDittmar, dimadin,
traversal, cmmarslender, Toddses, kokarn, welcher, and ericpedia.

Fixes #33982.


git-svn-id: https://develop.svn.wordpress.org/trunk@34928 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 02:30:18 +00:00
John Blackbourn
4046919a11 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 tests.

Fixes #16859


git-svn-id: https://develop.svn.wordpress.org/trunk@34920 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 23:38:22 +00:00
Boone Gorges
f9f92b223d Handle WP_User objects properly in update_user_caches().
We should not be storing the `WP_User` object in the cache, as it may contain
usermeta and other data that's cache elsewhere.

Props dd32.
See #24635.

git-svn-id: https://develop.svn.wordpress.org/trunk@34919 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 22:41:07 +00:00
Boone Gorges
e1d7108e79 Add tests for update_user_caches().
See #24635.

git-svn-id: https://develop.svn.wordpress.org/trunk@34918 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 22:34:32 +00:00
John Blackbourn
e40575aa99 Correctly set the scheme of the home and siteurl options when creating a new site on multisite that uses some combination of HTTPS in the admin area or on the front end.
Fixes #33620
Props tryon, johnbillion


git-svn-id: https://develop.svn.wordpress.org/trunk@34916 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 21:45:17 +00:00
John Blackbourn
6705184dcc Correctly encode the url parameter that gets passed to WordPress' own oEmbed endpoint URL.
Fixes #34193
Props ocean90


git-svn-id: https://develop.svn.wordpress.org/trunk@34915 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 21:42:36 +00:00
Gary Pendergast
43bd3d46c9 Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.

In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.

For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.

Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia

Fixes #32522.



git-svn-id: https://develop.svn.wordpress.org/trunk@34903 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 10:35:18 +00:00
Jeremy Felt
cce73768b3 Tests: Remove static capture of space used and space allowed.
Originally introduced in [34601], this was necessary to avoid test pollution. Now that things have been separated and written to play nicely, we can remove this.

See #34037.


git-svn-id: https://develop.svn.wordpress.org/trunk@34902 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 07:24:47 +00:00
Jeremy Felt
dadd89575f Tests: Improve tests for upload_is_user_over_quota().
* Move all tests to a new 'multisite/uploadIsUserOverQuota.php'
* Use `get_space_allowed` and `pre_get_space_used` filters to help avoid test pollution.

See #34037.


git-svn-id: https://develop.svn.wordpress.org/trunk@34901 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 07:20:45 +00:00
Jeremy Felt
b41be4c55c Tests: Account for non-numeric strings in tests for get_space_allowed().
Provides a specific test for a case where a non-numeric strings are assigned to `blog_upload_space` at both the site and network levels.

See #34037.


git-svn-id: https://develop.svn.wordpress.org/trunk@34900 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 06:16:58 +00:00
Jeremy Felt
b947cad868 Tests: Improve tests for is_upload_space_available().
* Move all tests to a new 'multisite/isUploadSpaceAvailable.php'
* Store original `blog_upload_space` values before the class is loaded.
* Restore these values after each test tear down to avoid pollution.

Commit to testing `is_upload_space_available()` itself by always filtering the amount of space used through `pre_get_space_used`. This allows us to sanely test without worrying about the local environment. In the future, we may be able to remove some of these tests as `get_upload_space_available()` tests are built out and reliable.

See #34037.


git-svn-id: https://develop.svn.wordpress.org/trunk@34899 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 06:14:14 +00:00
Jeremy Felt
8cf73c132d Tests: Improve tests for get_space_allowed().
* Move all tests to a new `multisite/getSpaceAllowed.php`
* Store original `blog_upload_space` values before the class is loaded.
* Restore these values after each test tear down to avoid pollution.
* Add a comprehensive set of expectations and results via data provider.

See #34037.


git-svn-id: https://develop.svn.wordpress.org/trunk@34898 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 04:57:12 +00:00
Scott Taylor
84df5f067c Rewrite/Permalinks/Canonical: in url_to_postid(), call set_url_scheme() on the URL to combat mixed content issues and find posts cross-scheme.
Adds unit tests.

Props swissspidy.
Fixes #34144.


git-svn-id: https://develop.svn.wordpress.org/trunk@34890 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 01:06:58 +00:00
Aaron Jorbin
351beec384 Revert [34875] due to unintentional breaking change
WordPress.org was taken down due to as Otto42 describes:

The previous version of this function added the query piece for the meta key = blog_id.capabilities, regardless of whether or not a role was requested. This limits the users returned to those with some defined role on this particular multisite instance.

See #22212




git-svn-id: https://develop.svn.wordpress.org/trunk@34880 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 20:57:35 +00:00
Aaron Jorbin
f17e457a16 Add message with status info to temperamental assertion.
The ajax delete comment tests are intermittently failing. Many of the assertions make it hard to tell why they are failing. This adds a message to one of those assertions that contains some info on what is being asserted with the goal that it helps developers understand why the failure is failing.

See #33968



git-svn-id: https://develop.svn.wordpress.org/trunk@34879 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 19:55:56 +00:00
Boone Gorges
1949734cf3 Improve role-related arguments in WP_User_Query.
* 'role' now accepts an array or comma-separated list of role names. When passing multiple values for 'role', `WP_User_Query` will only match users that have all of the specified roles.
* 'role__in' accepts an array of role names, and allow the filtering of matched users to those with at least one of the specified roles.
* 'role__not_in' accepts an array of role names, and allows the filtering of matched users to those who have none of the specified roles.

Props swissspidy, mordauk, barrykooij, sirbrillig.
Fixes #22212.

git-svn-id: https://develop.svn.wordpress.org/trunk@34875 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 17:39:23 +00:00
Aaron Jorbin
7825c097b8 Adjust detection of stream timeouts in maybe skip tests for https tests
This is a follow up to [34848].

See #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@34874 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 17:39:14 +00:00
Sergey Biryukov
f5b64d1674 Fix typo in [34848].
See #33968.

git-svn-id: https://develop.svn.wordpress.org/trunk@34872 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 17:27:12 +00:00
Drew Jaynes
3aca4edffa Tests: Update Tests_Rewrite_AddRewriteRule->setUp() to use the new set_permalink_structure() helper.
See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34870 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 16:01:38 +00:00
Drew Jaynes
7fe6d71d36 Users: Don't typo assertTrue() in a the uppercase letters validate_username() test.
See #24618.


git-svn-id: https://develop.svn.wordpress.org/trunk@34859 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 07:09:30 +00:00
Drew Jaynes
086d49daec Users: Add a separate test for checking the validity of a username containing uppercase characters in the scope of single vs multisite.
'JohnDoe' in single site: valid
'JohnDoe' in multisite: invalid

See #24618.


git-svn-id: https://develop.svn.wordpress.org/trunk@34858 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 07:01:32 +00:00
Gary Pendergast
536ba180df Tests: Dequeue the styles and scripts enqueued by Test_WP_Customize_Nav_Menus::test_enqueue_scripts().
Fixes #34163.



git-svn-id: https://develop.svn.wordpress.org/trunk@34857 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 05:47:17 +00:00
Drew Jaynes
afe594bb7c Users: Empty sanitized usernames should be considered invalid when passed through validate_username().
Adds tests.

Props gwinhlopez for the initial patch.
Props mordauk, chriscct7.
Fixes #24618.


git-svn-id: https://develop.svn.wordpress.org/trunk@34856 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 05:34:47 +00:00
Scott Taylor
fabd554bb2 Merge the Responsive Images feature plugin into core, initial commit. See: https://github.com/ResponsiveImagesCG/wp-tevko-responsive-images/
New functions in `media.php`:
* `wp_get_attachment_image_srcset_array()` - Returns an array of image candidate string data used to build a `srcset` value for an attachment given an `$attachement_id` and `$size`.
* `wp_get_attachment_image_srcset()` - Returns the `srcset` value for an attachment given an `$attachement_id` and `$size`.
* `wp_get_attachment_image_sizes()` - Returns the `sizes` value for an attachment given an `$attachement_id` and `$size` and optional arguments used to alter its output.
* `wp_make_content_images_responsive()` - A display filter for adding `srcset` and `sizes` to images embedded in content.
* `wp_img_add_srcset_and_sizes()` - A utility function used by `wp_make_content_images_responsive()` to add `srcset` and `sizes` to a single `<img>` element.

Modifies existing core functions:
* Modify `wp_get_attachment_image()` so the HTML returned for an image includes `srcset` and `sizes`.
* Modify `get_media_embedded_in_content()` (sup, 3.6 leftover) by adding `<img>` to the list of accepted tags that can be matched in content. This is used in `wp_make_content_images_responsive()` to find all of the images embedded in content before passing them off to `wp_img_add_srcset_and_sizes()`.

Tests:
* Add a new factory method to `WP_UnitTest_Factory_For_Attachment` named `create_upload_object()`
* Adds unit tests
* Updates unit tests

Props joemcgill, tevko, jaspermdegroot, mdmcginn, barryceelen, peterwilsoncc, fsylum, wonderboymusic, chriscoyier, benjaminpick, jrfnl, #12kingkool68, janhenckens, ryanmarkel, side777, ryelle, wturrell, micahmills, mattbagwell, coliff, DrewAPicture.
See #33641.


git-svn-id: https://develop.svn.wordpress.org/trunk@34855 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 04:58:21 +00:00
Gary Pendergast
da7ddeaeab Tests: Make the Attachment Slashes tests clean up after itself.
Fixes #34162.



git-svn-id: https://develop.svn.wordpress.org/trunk@34852 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 04:00:53 +00:00
Aaron Jorbin
7764297d7b Fix whitespace issues introduced in [34848]
Bad Jorbin.

See #33968


git-svn-id: https://develop.svn.wordpress.org/trunk@34849 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 03:40:46 +00:00
Aaron Jorbin
ba06fc4f5b HTTP timeouts should cause some tests to be skipped, not failed
A number of the HTTP external tests can inconstantly fail. As the HTTP API is one that doesn't change often, this failure creates noise. With the goal of increasing the signal from the unit tests, these tests are now skipped if they timeout. A notice is added when running the external http tests so that the developer knows what skipped tests may mean here.

See #33968



git-svn-id: https://develop.svn.wordpress.org/trunk@34848 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 03:36:18 +00:00
Scott Taylor
f3f892ce46 Rewrite: add tests for add_rewrite_rule().
Props DrewAPicture.
See #16840.


git-svn-id: https://develop.svn.wordpress.org/trunk@34847 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 03:35:14 +00:00
Weston Ruter
84e475dd80 Customizer: Ensure WP_Customize_Setting::update() returns boolean value.
Adds unit tests for `WP_Customize_Setting::save()` (and `WP_Customize_Setting::update()`), along with the actions `customize_update_{$type}`, and `customize_save_{$id_base}` which they trigger.

Fixes #34140.


git-svn-id: https://develop.svn.wordpress.org/trunk@34838 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-05 21:57:32 +00:00
Boone Gorges
578134d4ff Use wp_installing() instead of WP_INSTALLING constant.
The `WP_INSTALLING` constant is a flag that WordPress sets in a number of
places, telling the system that options should be fetched directly from the
database instead of from the cache, that WP should not ping wordpress.org for
updates, that the normal "not installed" checks should be bypassed, and so on.

A constant is generally necessary for this purpose, because the flag is
typically set before the WP bootstrap, meaning that WP functions are not yet
available.  However, it is possible - notably, during `wpmu_create_blog()` -
for the "installing" flag to be set after WP has already loaded. In these
cases, `WP_INSTALLING` would be set for the remainder of the process, since
there's no way to change a constant once it's defined. This, in turn, polluted
later function calls that ought to have been outside the scope of site
creation, particularly the non-caching of option data. The problem was
particularly evident in the case of the automated tests, where `WP_INSTALLING`
was set the first time a site was created, and remained set for the rest of the
suite.

The new `wp_installing()` function allows developers to fetch the current
installation status (when called without any arguments) or to set the
installation status (when called with a boolean `true` or `false`). Use of
the `WP_INSTALLING` constant is still supported; `wp_installing()` will default
to `true` if the constant is defined during the bootstrap.

Props boonebgorges, jeremyfelt.
See #31130.

git-svn-id: https://develop.svn.wordpress.org/trunk@34828 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-05 15:05:26 +00:00
Drew Jaynes
b1ed6b5f18 Widgets: Add more tests for registering and unregistering sidebars with 1) no ID, 2) a string ID, 3) a numeric ID.
See #17078.


git-svn-id: https://develop.svn.wordpress.org/trunk@34817 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-04 05:22:11 +00:00
Drew Jaynes
572fd0a45b Widgets: Add tests for dynamic_sidebar() where sidebars were registered with 1) no supplied ID, 2) a numeric ID, 3) a string ID.
See #17078.


git-svn-id: https://develop.svn.wordpress.org/trunk@34816 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-04 04:43:46 +00:00
Boone Gorges
ffa997a342 Update the taxonomy relationship cache in is_object_in_term().
This function attempts to read from the relationship cache, and uses any data
it finds. If it finds no data, it does a query for the data it needs. Since we
are going to the trouble to query for the relationships, and since we are
already using cached data when available, let's go ahead and cache it for
later use.

Props joehoyle, boonebgorges.
Fixes #32044.

git-svn-id: https://develop.svn.wordpress.org/trunk@34812 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 21:18:55 +00:00
Drew Jaynes
0ea2acb720 Tests: Permalink Structures Phase II: DRY up logic for setting permalink structures in test methods.
Renames `reset_permalinks()` to `set_permalink_structure()` (mimicking `$wp_rewrite->set_permalink_structure()`) and allows it to accept an optional permalink structure. In this way, we can double dip using it to both set and reset the permalink structure from anywhere.

Removes alot of duplicated code from tests.

See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34810 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 20:54:11 +00:00
Boone Gorges
eebe549408 When creating terms, avoid false dupe checks due to accented characters.
`wp_insert_term()` doesn't allow the creation of a term when the term `name`
is the same as another term in the same hierarchy level of the same taxonomy.
Previously, this duplicate check used `get_term_by( 'name' )`, which uses the
database collation to determine sameness. But common collations do not
distinguish between accented and non-accented versions of a character. As a
result, it was impossible to create a term 'Foo' if a sibling term with an
accented character existed.

We address this problem by using `get_terms()` to do the duplicate check. This
query returns all potentially matching terms. We then do a stricter check
for equivalence in PHP, before determining whether one of the matches is
indeed a duplicate.

Props boonebgorges, tyxla, geza.miklo, mehulkaklotar.
Fixes #33864.

git-svn-id: https://develop.svn.wordpress.org/trunk@34809 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 20:24:09 +00:00
Drew Jaynes
01f25fa247 Tests: Last try: It's redundant to reset permalinks on tearDown() if we're already doing it on every setUp().
Removes the restoration logic, which leveraged a static property initialized with `get_option()`.

See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34807 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 19:26:24 +00:00
Boone Gorges
3b89b3ca28 Use 'comments_per_page' option as fallback in get_page_of_comment().
The function now uses the following order of precedence when calculating
comment pagination: 1. the 'per_page' value passed in the `$args` array,
2. the 'comments_per_page' query var in `$wp_query`, and 3. the
'comments_per_page' setting from options-discussion.php. This change allows
`get_page_of_comment()` to return an accurate value before the main query
has been run.

Props laceous.
See #13939.

git-svn-id: https://develop.svn.wordpress.org/trunk@34806 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 19:25:25 +00:00
Boone Gorges
ddc75e22ee Only count top-level comments when calculating threaded pagination.
The change in [34535] did not properly account for threading.

See #13939, #11334.

git-svn-id: https://develop.svn.wordpress.org/trunk@34805 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 19:15:55 +00:00
Boone Gorges
b240a2a939 Ensure that WP_User_Query vars are filled after 'pre_get_users'.
This prevents notices from being thrown when a 'pre_get_users' callback
removes required values from the list of `query_vars`.

For backward compatibility with previous uses of 'pre_get_users', default
values are parsed both before and after the action is fired.

Fixes #33449.

git-svn-id: https://develop.svn.wordpress.org/trunk@34804 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 18:44:40 +00:00
Drew Jaynes
9cdffaaed8 Tests: Move the global permalinks reset routine to only fire when running core tests.
Should fix intermittent mysqli response errors in the AJAX tests.

See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34803 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 18:35:58 +00:00
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