Commit Graph

1950 Commits

Author SHA1 Message Date
Jeremy Felt
56c98dd30a Tests: Split get_blog_details() test into individual tests
* One test per method
* Clarify existing tests.
* Add test for passing a "blog slug" string to `get_blog_details()`.
* Shared fixture of sites.
* Reduce number of sites created to only those necessary.
* Remove unnecessary networks creation.

See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37666 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-09 15:57:37 +00:00
Jeremy Felt
ead348053b Tests: Move get_blog_details() tests to their own file
See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37665 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-09 05:40:45 +00:00
Jeremy Felt
8de500d493 Tests: User a data provider for wp_get_sites() tests.
* Convert existing tests into a data provider and clarify expectations.
* Add shared test fixtures in preparation for future tests.

This passes with the `wp_get_sites()` from 4.5 and the deprecated version in trunk.

See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37662 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-09 00:27:46 +00:00
Jeremy Felt
8e380e50d8 Tests: Move wp_get_sites() tests to their own file
See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37660 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-08 22:46:38 +00:00
Boone Gorges
ca05a4b43d Comments: In wp_list_comments(), queries with custom pagination params should obey default comment_status logic.
When custom pagination parameters are passed to `wp_list_comments()`, a
secondary query must be performed to fetch the proper comments. See [36157].
This query should show comments of the same `comment_status` as the default
query initialized in `comments_template()`: show only comments that are
approved, or those that are unapproved but belong to the current user.

Props smerriman.
Fixes #37048.

git-svn-id: https://develop.svn.wordpress.org/trunk@37655 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-08 04:00:18 +00:00
Gary Pendergast
5c4a15d0fc Tests: Disable foreign_key_checks while dropping existing tables.
To ensure a clean run, the test suite drops all tables before installing, by simply looping over the table list and dropping them if they exist. This works well for Core, but may fail when a plugin has created a table with foreign key constraints in a previous test run.

Many plugins choose to base their test suite on the Core setup, so making life easier for them is a plus, even if Core doesn't directly need this change.

Props javorszky.

Fixes #37046.



git-svn-id: https://develop.svn.wordpress.org/trunk@37654 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-08 03:03:16 +00:00
Jeremy Felt
6da085cfe4 Multisite: Deprecate wp_get_sites()
Defer to the new `get_sites()` replacement, offering fresh (...or cached) `WP_Site` objects via the new `WP_Site_Query`.

Props flixos90.
Fixes #36994.


git-svn-id: https://develop.svn.wordpress.org/trunk@37653 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-08 03:02:34 +00:00
Boone Gorges
a1e19248a3 Tests: Compare wp_set_object_terms() results using term_taxonomy_id.
`term_id` and `term_taxonomy_id` become offset when running the entire test
suite.

Introduced in [37647].

See #37009.

git-svn-id: https://develop.svn.wordpress.org/trunk@37649 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-06 23:42:43 +00:00
Dominik Schilling (ocean90)
30b1f09c21 Widgets: Revert [37425] and [37427].
The change can cause fatal errors under certain conditions, like when the subclass has a different function signature for `widget()` or doesn't even implement the method.

See #35981.

git-svn-id: https://develop.svn.wordpress.org/trunk@37648 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-06 21:50:29 +00:00
Boone Gorges
8d40956f7a Tests: Add tests demonstrating wp_set_object_terms() behavior when matching $terms.
See #37009.

git-svn-id: https://develop.svn.wordpress.org/trunk@37647 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-06 21:34:22 +00:00
Rachel Baker
25c3618138 REST API: Create the general wp_check_jsonp_callback() function for validating JSONP callback functions.
Move the REST API JSONP callback validation check into a separate function named `wp_check_jsonp_callback()`. This allows plugins to use the built-in validation when handling JSONP callbacks.
Extremely Important Note: If you send JSONP in your custom response, make sure you prefix the response with `/**/`. This will mitigate the Rosetta Flash exploit. You should also send the `X-Content-Type-Options:nosniff` header, or even better, use the REST API infrastructure.

Props rmccue.
Fixes #28523.

git-svn-id: https://develop.svn.wordpress.org/trunk@37646 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-06 21:33:30 +00:00
Boone Gorges
cc7d91f141 Tests: Move wp_set_object_terms() tests to their own file.
This is a redo of [37642], this time not done in the not right place.

See #37009.


git-svn-id: https://develop.svn.wordpress.org/trunk@37644 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-06 21:22:43 +00:00
Boone Gorges
b189d26960 Add test demonstrating that wp_insert_term() will suffix a slug if the new term's auto-generated slug matches that of an existing term.
See #37009.

git-svn-id: https://develop.svn.wordpress.org/trunk@37641 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-06 21:03:34 +00:00
Boone Gorges
a77ffd8e83 Taxonomy: No, really, don't pass results of 'count' query through 'get_terms' filter.
[37623] used the wrong parameter name (count=true instead of fields=count).

For greater flexibility and forward compatibility with other potential changes
to the return value of `get_terms()`, we now do a looser check: any non-array
value is excluded from the filter.

Fixes #36992.

git-svn-id: https://develop.svn.wordpress.org/trunk@37634 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-04 12:19:15 +00:00
Jeremy Felt
91859d2098 Multisite: Add initial tests for WP_MS_Sites_List_Table
Different tests are used for subdomain and subdirectory installs as domain and path are searched differently for each. Only trailing wildcard searches are tested because leading wildcards are not yet supported.

See #36675.


git-svn-id: https://develop.svn.wordpress.org/trunk@37633 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-03 14:38:01 +00:00
Boone Gorges
9f21bd49bc Add tests for remove_query_arg().
Props borgesbruno.
Fixes #37008.

git-svn-id: https://develop.svn.wordpress.org/trunk@37631 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-03 04:30:23 +00:00
Andrew Ozz
245709dcd1 Auto-embedding:
- We already match URLs on their own line, add another regex to match URLs in their own paragraphs.
- Always exclude the `\s<>"` characters when matching.
- Add more unit tests.

Props iseulde, azaozz.
Fixes #25387.

git-svn-id: https://develop.svn.wordpress.org/trunk@37627 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-02 21:23:43 +00:00
Boone Gorges
1f5147bf83 Comments: Improve caching for hierarchical queries.
Hierarchical comment queries work by first fetching the IDs of top-level
comments, and then filling the descendant tree one level at a time based on the
top-level results. When top-level comment IDs are found in the cache,
`WP_Comment_Query` does not generate the SQL used to fetch these comments. In
this case, the `fill_descendants()` query does not have enough information
to fill children. As a result, descendant comments were failing to be filled
in cases where the top-level comments were found in the cache.

This was a minor bug previously, because comment caches were not maintained
between pageloads. Since comment caches are now persistent [37613], the problem
becomes evident anywhere that a persistent object cache is in use.

The solution is to cache parent-child relationships, so that when top-level
comments are found in the cache, descendant comments should be found there as
well.

Fixes #36487.

git-svn-id: https://develop.svn.wordpress.org/trunk@37625 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-02 18:27:43 +00:00
Boone Gorges
f6a2067d37 Taxonomy: Don't pass results of 'count' query through 'get_terms' filter.
Use of the 'get_terms' filter was consolidated in [37572], with the
introduction of `WP_Term_Query`. At that time, the result of 'count=true'
queries began being filtered by 'get_terms'. This breaks existing 'get_terms'
callbacks, which often assume that the returned value will be an array or a
`WP_Error` object.

Props JustinSainton.
Fixes #36992.

git-svn-id: https://develop.svn.wordpress.org/trunk@37623 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-02 14:37:55 +00:00
Boone Gorges
04d01a8eb4 Add tests demonstrating individual comment cache invalidation.
See #36906.

git-svn-id: https://develop.svn.wordpress.org/trunk@37609 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-01 17:15:27 +00:00
Boone Gorges
425fffeb4f Add tests demonstrating query cache invalidation on comment CRUD actions.
See #36909.

git-svn-id: https://develop.svn.wordpress.org/trunk@37608 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-01 16:59:16 +00:00
Gary Pendergast
0e8e778af9 Tests: Fix an incorrect @ticket header introduced in [37601].
See #32405, #36917.



git-svn-id: https://develop.svn.wordpress.org/trunk@37602 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-01 02:40:19 +00:00
Gary Pendergast
bc975d28d4 Database: Split the logic of wpdb::init_charset() into a separate method.
The logic for determining the appropriate character set and collation to use is becoming more complex, particularly with the recent additions of [37522] and [37523]. As `init_charset()` has side effects, and makes use of constants instead of parameters, it's not possible to unit test this logic.

This commit splits the logic part of `init_charset()` out into a new method, `wpdb::determine_charset()`, along with appropriate unit tests.

See #32105, #37522.

Fixes #36917.



git-svn-id: https://develop.svn.wordpress.org/trunk@37601 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-01 02:37:20 +00:00
Boone Gorges
5fdf2b4b44 Add tests for no_found_rows behavior of WP_Query.
See #29952.

git-svn-id: https://develop.svn.wordpress.org/trunk@37600 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-31 19:28:46 +00:00
Boone Gorges
9b19a33952 Ensure that get_terms() can accept querystring-style arguments.
Prior to [37572], arguments passed to `get_terms()` were passed immediately
through `wp_parse_args()`, which made it possible to pass arguments as a
querystring (`hide_empty=0`) rather than an array
(`array( 'hide_empty' => false )`). [37572] moved default argument parsing
into `WP_Term_Query`, while assuming that arguments passed to `get_terms()`
would be formatted as an array.

To provide compatibility, we now parse all args passed to `get_terms()` into
an array before processing.

See #35381.

git-svn-id: https://develop.svn.wordpress.org/trunk@37599 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-31 12:53:27 +00:00
Boone Gorges
8f06d6678b Tests: Change some 'group' annotations to 'ticket'.
git-svn-id: https://develop.svn.wordpress.org/trunk@37595 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-30 04:37:57 +00:00
Boone Gorges
cb5b8479f0 In WP_Meta_Query, don't cast meta_value to CHAR.
`CHAR` is redundant, since the `meta_value` column is `LONGTEXT`. Meanwhile,
use of `CAST()` causes MySQL to ignore any index that the administrator may
have added to the column.

A number of automated tests were doing searches for `CAST` in the SQL strings
generated by `WP_Meta_Query` (for reasons unrelated to the `CAST()` behavior).
These tests have been updated to expect the new query format.

Props ericlewis.
Fixes #36625.

git-svn-id: https://develop.svn.wordpress.org/trunk@37594 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-30 04:35:16 +00:00
Boone Gorges
23d0c953d2 Don't clear object relationship caches on term update.
Since [37573], object relationship caches (`{$taxonomy}_relationships`)
contain term IDs rather than term objects. See #36814. As such, it's no longer
necessary to clear these caches when a term is updated; none of the data that's
changed on update (name, description, count, etc) is stored in the relationship
cache.

Fixes #36251.

git-svn-id: https://develop.svn.wordpress.org/trunk@37593 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-30 04:10:16 +00:00
Boone Gorges
c96858b0f2 Allow term meta lazy-loading to be selectively disabled in WP_Query.
The process of lazy-loading can be resource intensive for object that have
terms in large numbers of taxonomies and are running a persistent object cache.
This new parameter allows the feature to be disabled in these cases.

Props DBrumbaugh10Up.
See #36953.

git-svn-id: https://develop.svn.wordpress.org/trunk@37589 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-28 03:09:09 +00:00
Aaron Jorbin
13350c95e4 Bootstrap/Load: Load plugin.php earlier in wp-settings.php
In order to allow non-web initializations of WordPress (such as through wp-cli) to modify things like the check for maintenance mode, plugins.php and the associated functions must be available much earlier. The use of these functions earlier than the loading of plugins is not recommended in most use cases.

Fixes #36819. See #34936.
Props jorbin, danielbachhuber for documentation.


git-svn-id: https://develop.svn.wordpress.org/trunk@37588 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-27 19:19:12 +00:00
Dominik Schilling (ocean90)
35a7acb459 Database: Normalize index definitions in dbDelta().
`dbDelta()` compares the index definitions against the result of `SHOW INDEX FROM $table_name`. This requires a specific format so indices are not unnecessarily re-created. This format wasn't ensured, until now.

* Parse the raw index definition to extract the type, name and columns so a normalized definition can be built (#20263, #34873).
* Standardize on uppercase types (#34871) and on 'KEY'. 'INDEX' is only a synonym for 'KEY'.
* Escape index names with backticks (#20263).
* Normalize columns: Ignore ASC and DESC definitions (#34959), remove whitespaces (#34869) and escape column names with backticks (#20263).
* Add backticks to all index change queries (#20263).

Props ocean90, pento, kurtpayne.
Fixes #20263, #34869, #34871, #34873, #34959.

git-svn-id: https://develop.svn.wordpress.org/trunk@37583 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-27 11:56:20 +00:00
Boone Gorges
2c7f879188 Add tests for get_weekstartend().
Props pbearne, tloureiro.
Fixes #36415.

git-svn-id: https://develop.svn.wordpress.org/trunk@37579 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-26 15:47:52 +00:00
Gary Pendergast
a51a68fb75 Database: Add support for SPATIAL keys to dbDelta().
`dbDelta()` already supported spatial fields (by virtue of not checking field types), so it's nice to round that out with spatial key support, too.

Fixes #36948.



git-svn-id: https://develop.svn.wordpress.org/trunk@37574 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-26 04:58:13 +00:00
Boone Gorges
96b71d7d89 Store only term IDs in object term relationships caches.
Previously, objects containing all data about a term were stored in each
object's term cache. Besides being wasteful, this approach caused invalidation
issues, as when a modified term count required a flush for all objects
belonging to the term.

Backward compatibility is maintained for plugins that continue to put object
data directly into the `{$taxonomy}_relationships` cache bucket.

Fixes #36814.

git-svn-id: https://develop.svn.wordpress.org/trunk@37573 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-26 04:49:10 +00:00
Boone Gorges
a378749df6 Fix termmeta pre-fetching in wp_get_object_terms().
[34529] introduced logic intended to prime the termmeta cache for certain
values of the `fields` parameter. There were a few bugs:

* The `all_with_object_id` param was misspelled.
* `term_id` was used instead of `ids`.
* The values being passed to `update_termmeta_cache()` in the case where `fields=ids` was not correct.

All of these would result in a failure to pre-fetch termmeta in some cases.

Props dlh.
Fixes #36932.

git-svn-id: https://develop.svn.wordpress.org/trunk@37567 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-25 18:44:00 +00:00
Drew Jaynes
c013727ebe Posts: Add test coverage for get_preview_post_link().
Props swissspidy.
Fixes #35915.


git-svn-id: https://develop.svn.wordpress.org/trunk@37566 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-25 18:30:57 +00:00
Boone Gorges
1d3511ba8c In get_bookmarks(), don't cache if 'orderby=rand'.
Props lukecavanagh, prettyboymp, c3mdigital, MikeHansenMe.
Fixes #18356.

git-svn-id: https://develop.svn.wordpress.org/trunk@37565 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-25 18:29:01 +00:00
Boone Gorges
ec53bf5bf6 Add tests for get_bookmarks() cache.
This changeset adds a unit test factory so that bookmark/link fixtures can be
created during tests.

Why are we writing tests for functionality that has been deprecated for years?
Because it's the Right Thing to Do.

See #18356.

git-svn-id: https://develop.svn.wordpress.org/trunk@37563 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-25 18:20:24 +00:00
Ella Iseulde Van Dorpe
e20bc6cc46 Media: adjust test after [37556]
See #36888.



git-svn-id: https://develop.svn.wordpress.org/trunk@37557 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-25 14:05:34 +00:00
Dominik Schilling (ocean90)
52caa1f06a Database: Support backticks around field names when parsing a query for the field type.
Avoids an undefined index PHP warning by `dbDelta()`.

Props davidmosterd, ocean90.
See #20263.

git-svn-id: https://develop.svn.wordpress.org/trunk@37538 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-23 18:11:32 +00:00
Gary Pendergast
2d14d5abab Database: dbDelta() will no longer try to downgrade the size of TEXT and BLOB columns.
When upgrading to `utf8mb4`, `TEXT` fields will be upgraded to `MEDIUMTEXT` (and likewise for all other `*TEXT` and `*BLOB` fields). This is to allow for the additional space requirements of `utf8mb4`.

On the subsequent upgrade, after the `utf8mb4` upgrade, `dbDelta()` would try and downgrade the fields to their original size again. At best, this it a waste of time, at worst, this could truncate any data larger than the original size. There's no harm in leaving them at their original size, so let's do that.

Fixes #36748.



git-svn-id: https://develop.svn.wordpress.org/trunk@37525 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-23 08:35:59 +00:00
Gary Pendergast
c231052280 Tests: Remove a test for a function that can't be tested.
`wpdb::init_charset()` doesn't lend itself to being tested, so the unit test added in [37521] won't work under most circumstances.

See #32405.



git-svn-id: https://develop.svn.wordpress.org/trunk@37522 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-23 06:26:01 +00:00
pento
4422aac17c Database: Obey locale-specific utf8 collation settings.
Some sites prefer to use locale-specific location settings. For example, the Swedish WordPress package use `utf8_swedish_ci`, instead of `utf8_unicode_ci`. When upgrading the connection to `utf8mb4`, we were overriding this to be `utf8mb4_unicode_ci`, instead of maintaining the use of the `_swedish_ci` variant.

The locale-specific collations do have extra collation rules just for that language, so it's useful to maintain compatibility.

Fixes #32405.




git-svn-id: https://develop.svn.wordpress.org/trunk@37521 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-23 05:53:02 +00:00
Boone Gorges
dd70966885 Tests: get_terms() 'search' test should have more precise fixtures..
Without a fixture that does not match the search term, it's possible for the
test to pass even if the search clause isn't built properly.

See #13992, #35381.

git-svn-id: https://develop.svn.wordpress.org/trunk@37519 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-23 03:25:51 +00:00
Boone Gorges
3e3b09c8ea In get_page_by_path(), values fetched from cache should obey $output param.
Introduced in [37479].

Props spacedmonkey.
Fixes #36711.

git-svn-id: https://develop.svn.wordpress.org/trunk@37481 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-22 16:18:22 +00:00
Boone Gorges
56a3d4bb65 Move get_the_terms() tests to their own file.
See #36814.


git-svn-id: https://develop.svn.wordpress.org/trunk@37480 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-21 17:56:40 +00:00
Boone Gorges
1a39a00dfd Cache queries in get_page_by_path().
Props spacedmonkey.
Fixes #36711.

git-svn-id: https://develop.svn.wordpress.org/trunk@37479 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-21 17:26:55 +00:00
Boone Gorges
70fece5c7e Tests: Improve tests for get_page_by_path().
* Move existing test into its own file.
* Add tests that cover most pieces of functionality.

See #36711.

git-svn-id: https://develop.svn.wordpress.org/trunk@37478 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-21 02:40:56 +00:00
Jeremy Felt
381930974c Multisite: Introduce WP_Site_Query
Provides a consistent way to query `$wpdb->blogs` for `WP_Site` objects based on domain, path, site ID, network ID, and more.

Introduces and uses `update_site_cache()` and `_prime_site_caches()` to maintain a cached list of `WP_Site` objects for use in multiple queries.

Props spacedmonkey, flixos90, DrewAPicture, jeremyfelt, ocean90.
See #35791.


git-svn-id: https://develop.svn.wordpress.org/trunk@37477 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-20 22:03:52 +00:00
Weston Ruter
c7ff79df64 Customize: Add setting validation model and control notifications to augment setting sanitization.
When a setting is invalid, not only will it be blocked from being saved but all other settings will be blocked as well. This ensures that Customizer saves aren't partial but are more transactional. User will be displayed the error in a notification so that they can fix and re-attempt saving.

PHP changes:

* Introduces `WP_Customize_Setting::validate()`, `WP_Customize_Setting::$validate_callback`, and the `customize_validate_{$setting_id}` filter.
* Introduces `WP_Customize_Manager::validate_setting_values()` to do validation (and sanitization) for the setting values supplied, returning a list of `WP_Error` instances for invalid settings.
* Attempting to save settings that are invalid will result in the save being blocked entirely, with the errors being sent in the `customize_save_response`. Modifies `WP_Customize_Manager::save()` to check all settings for validity issues prior to calling their `save` methods.
* Introduces `WP_Customize_Setting::json()` for parity with the other Customizer classes. This includes exporting of the `type`.
* Modifies `WP_Customize_Manager::post_value()` to apply `validate` after `sanitize`, and if validation fails, to return the `$default`.
* Introduces `customize_save_validation_before` action which fires right before the validation checks are made prior to saving.

JS changes:

* Introduces `wp.customize.Notification` in JS which to represent `WP_Error` instances returned from the server when setting validation fails.
* Introduces `wp.customize.Setting.prototype.notifications`.
* Introduces `wp.customize.Control.prototype.notifications`, which are synced with a control's settings' notifications.
* Introduces `wp.customize.Control.prototype.renderNotifications()` to re-render a control's notifications in its notification area. This is called automatically when the notifications collection changes.
* Introduces `wp.customize.settingConstructor`, allowing custom setting types to be used in the same way that custom controls, panels, and sections can be made.
* Injects a notification area into existing controls which is populated in response to the control's `notifications` collection changing. A custom control can customize the placement of the notification area by overriding the new `getNotificationsContainerElement` method.
* When a save fails due to setting invalidity, the invalidity errors will be added to the settings to then populate in the controls' notification areas, and the first such invalid control will be focused.

Props westonruter, celloexpressions, mrahmadawais.
See #35210.
See #30937.
Fixes #34893.


git-svn-id: https://develop.svn.wordpress.org/trunk@37476 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-20 21:09:40 +00:00
Jeremy Felt
757c0767f7 Multisite: Wrap the main bootstrap process in a function
Introduce `ms_load_current_site_and_network`. This is used by core during the multisite bootstrap process to populate the `$current_site` and `$current_blog` globals based on a requested domain and path.

Return values from this function inform `ms-settings.php` as to whether a page view should continue, `ms_not_installed()` should fire, or a redirect to a new location should occur.

This was previously a procedural block in `ms-settings.php`. Wrapping this code and providing specific return values allows us to write tests that do not rely on the manual and repeated inclusion of `ms-settings.php`.

This should not be used by plugins or themes. Please.

See #34941.


git-svn-id: https://develop.svn.wordpress.org/trunk@37475 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-20 20:56:54 +00:00
Peter Wilson
761dde5ee9 Emoji: Use SVG in supported browsers
Use SVG images in supporting browsers, otherwise fall back to PNG images. Add the filters `emoji_svg_url` and `emoji_svg_ext`.

Introduces unit tests to check the Emoji CDN filters.

Fixes #36525


git-svn-id: https://develop.svn.wordpress.org/trunk@37471 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-20 06:02:55 +00:00
Gary Pendergast
8a779ede82 Tests: Fix an incorrect @ticket header included in [37469].
See #36122.



git-svn-id: https://develop.svn.wordpress.org/trunk@37470 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-20 05:29:50 +00:00
Gary Pendergast
6d963d60c6 Emoji: Allow emoji in blogname and blogdescription on utf8 installs.
When the options table is set to `utf8` instead of `utf8mb4`, emoji will be stripped from the blog name and description when they're saved. Instead of stripping them, they can be encode as HTML entities.

Fixes #36122.



git-svn-id: https://develop.svn.wordpress.org/trunk@37469 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-20 04:53:40 +00:00
Boone Gorges
63755028e8 Introduce required argument for wp_dropdown_categories().
This allows the HTML5 `required` attribute to be added to the `select` element.

Props wzislam, pcarvalho.
Fixes #31909.

git-svn-id: https://develop.svn.wordpress.org/trunk@37465 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-19 02:38:33 +00:00
Boone Gorges
510bbfcb9c Move wp_dropdown_categories() tests into their own file.
See #31909.


git-svn-id: https://develop.svn.wordpress.org/trunk@37464 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-19 02:22:59 +00:00
Aaron Jorbin
63cdf85fad Correct usage of @Covers for Tests_Post_Types
When @covers is used with a plain alphanumeric string, PHPUnit assumes that it is covering a class. If there is no class, it fails and exits rather than continuing to generate coverage. To cover a global function, the name must start with ::. See https://phpunit.de/manual/5.3/en/appendixes.annotations.html#appendixes.annotations.covers

Introduced in [36768].

Fixes #36867. See #35985



git-svn-id: https://develop.svn.wordpress.org/trunk@37459 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-18 17:13:11 +00:00
Aaron Jorbin
ead6585754 Correct usage of Covers for Tests_Update_Comment_Count_Now
When @covers is used with a plain alphanumeric string, PHPUnit assumes that it is covering a class. If there is no class, it fails and exits rather than continuing to generate coverage. To cover a global function, the name must start with ::. See https://phpunit.de/manual/5.3/en/appendixes.annotations.html#appendixes.annotations.covers

[37445] for trunk

See #35060, #36867



git-svn-id: https://develop.svn.wordpress.org/trunk@37447 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-17 20:19:50 +00:00
Boone Gorges
55961a5613 Tests: Use factory method to generate fixtures for wp_unique_post_slug() tests.
Props mintindeed.
See #20419.

git-svn-id: https://develop.svn.wordpress.org/trunk@37443 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-17 01:48:58 +00:00
Dominik Schilling (ocean90)
999af2444c I18N: In get_translations_for_domain() check if the global $l10n was set by _load_textdomain_just_in_time() before accessing it.
Props danielhuesken.
Fixes #34114.

git-svn-id: https://develop.svn.wordpress.org/trunk@37440 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-16 15:09:33 +00:00
Ryan McCue
9074e9f93b HTTP API: Replace internals with Requests library.
Requests is a library very similar to WP_HTTP, with a high level of unit test coverage, and has a common lineage and development team. It also supports parallel requests.

See #33055.


git-svn-id: https://develop.svn.wordpress.org/trunk@37428 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-13 04:41:45 +00:00
Dominik Schilling (ocean90)
e2329076f3 Widgets: Create WP_Widget_Mock as a mock of WP_Widget which can be used for widget tests.
You cannot instantiate an abstract class. Not even in WordPress world.

See #35981.

git-svn-id: https://develop.svn.wordpress.org/trunk@37427 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-12 21:24:18 +00:00
Jeremy Felt
4429638da6 Tests: Set public to 1 in the default blog factory
When no `$meta` arguments are passed to `wpmu_create_blog()`, `public` is set to `0` in the database for new sites. This is fine, but also does not match the default implied when most sites are created via `site-new.php`.

The only current use of the `$meta` argument in the tests is to (re)mark `public` as `0`. All existing tests pass with this change. Tests for `WP_Site_Query` can now rely on better default expectations.

See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37418 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-11 19:21:22 +00:00
Pascal Birchler
0151b0ebae I18N: Remove the requirement to call load_plugin_textdomain() / load_theme_textdomain().
By initially scanning the `wp-content/languages` directory and loading available MO files just-in-time, plugins and themes do not need to manually load text domains anymore.

Props swissspidy, ocean90.
Fixes #34114

git-svn-id: https://develop.svn.wordpress.org/trunk@37415 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-10 20:04:52 +00:00
Weston Ruter
8359290d8f Customize: Ensure that wp_setup_nav_menu_item filter applies consistently on nav_menu_item setting values.
The filter was being applied in `WP_Customize_Nav_Menu_Item_Setting::value()` but not in `WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item()`.

Props celloexpressions, westonruter.
Fixes #35203.


git-svn-id: https://develop.svn.wordpress.org/trunk@37405 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-10 06:40:48 +00:00
Dominik Schilling (ocean90)
41cfd4d826 Tests: Don't create unused users in Tests_Ajax_DeleteComment.
Fixes #36616.

git-svn-id: https://develop.svn.wordpress.org/trunk@37404 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-09 19:16:35 +00:00
Boone Gorges
f3ccef62be Users: The 'who' parameter should not interfere with 'meta_key' + 'meta_value' in WP_User_Query.
Props adrianosilvaferreira.
Fixes #36724.

git-svn-id: https://develop.svn.wordpress.org/trunk@37360 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-04 18:56:58 +00:00
Boone Gorges
e415270afb Tests: Correct 'meta_query' syntax in test related to WP_User_Query 'who' param.
The test, introduced in [32207], used the incorrect syntax for 'meta_query' -
one fewer level of array-nesting than what `WP_Meta_Query` requires. This
slip uncovered a bug introduced into `WP_User_Query` in [30094], whereby
an incorrectly formatted 'meta_query' parameter would be properly parsed by
`WP_User_Query` when passed alongside `who=authors`.

We need to fix the inconsistent syntax in order to resolve #36724.

See #36724, #32019, #23849, #27026.

git-svn-id: https://develop.svn.wordpress.org/trunk@37359 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-04 18:48:08 +00:00
Boone Gorges
8e417dd09b Tests: Introduce reset_phpmailer_instance() function.
This function provides a more convenient method for resetting the
PHPMailer instance than the previous technique of reaching into the global.

Props welcher.
Fixes #36658.

git-svn-id: https://develop.svn.wordpress.org/trunk@37358 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-04 03:48:46 +00:00
Boone Gorges
23b3f3e2ee Add tests for is_serialized_string().
Props borgesbruno.
Fixes #35952.

git-svn-id: https://develop.svn.wordpress.org/trunk@37357 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-04 03:29:47 +00:00
Weston Ruter
0321612c4d Customize: Handle filtering sidebars_widgets when the underlying option is non-existent.
Fixes warning related to a non-array argument for `array_merge()` in `WP_Customize_Widgets::customize_register()`. 

See [37166].
See #36389.
Fixes #36660.


git-svn-id: https://develop.svn.wordpress.org/trunk@37352 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-02 23:41:18 +00:00
Weston Ruter
018f988654 Customize: Pass WP_Customize_Setting instance as second argument to customize_value_{$id_base} filter.
Adds parity with setting instance being passed as second argument to `customize_sanitize_{$id}` and `customize_sanitize_js_{$id}`. Allows the actual ID of the (multidimensional) setting value being filtered to be inspected.

Props celloexpressions, westonruter.
Fixes #36452.


git-svn-id: https://develop.svn.wordpress.org/trunk@37350 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-02 22:41:36 +00:00
Drew Jaynes
0f468dd456 Comments: Adjust comment_author_email_link() and get_comment_author_email_link() to each accept a new optional fourth parameter, $comment, which enables overriding the $comment global.
Adds tests.

Props flixos90, boonebgorges, DrewAPicture.
See #36571.


git-svn-id: https://develop.svn.wordpress.org/trunk@37348 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-02 19:58:23 +00:00
Eric Andrew Lewis
32ed4fadf2 Posts: Allow get_page_uri() to be called without a $page argument.
`get_page_uri()` can now be called without an argument, which will return the page URI for the current post in the loop.

Props pollett.
Fixes #26284.


git-svn-id: https://develop.svn.wordpress.org/trunk@37345 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-02 18:28:04 +00:00
Drew Jaynes
0efe87a4fb Tests: Remove debug cruft left over from [34816].
See #17078.


git-svn-id: https://develop.svn.wordpress.org/trunk@37344 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-02 16:23:47 +00:00
Weston Ruter
f660ffb601 Widgets: Provide PHP 5.2 fallback for spl_object_hash() if disabled in logic for registering and unregistering pre-instantiated widgets.
Fixes #28216.


git-svn-id: https://develop.svn.wordpress.org/trunk@37333 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-30 22:35:27 +00:00
Dominik Schilling (ocean90)
d62141c38d Plugins: In plugin_basename() normalize the file path before unresolving symlinks.
`$wp_plugin_paths` contains normalized paths, see `wp_register_plugin_realpath()`.

Props jdgrimes, voldemortensen, flyingdr, ocean90.
Fixes #29154.

git-svn-id: https://develop.svn.wordpress.org/trunk@37332 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-30 15:08:06 +00:00
Weston Ruter
7ad11aaad8 Widgets: Allow WP_Widget subclass instances (objects) to be registered/unregistered in addition to WP_Widget subclass names (strings).
Allows widgets to be registered which rely on dependency injection. Also will allow for new widget types to be created dynamically (e.g. a Recent Posts widget for each registered post type).

See #35990.
Props mdwheele, PeterRKnight, westonruter.
Fixes #28216.


git-svn-id: https://develop.svn.wordpress.org/trunk@37329 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-29 18:48:27 +00:00
Scott Taylor
ec0614cf17 Media/Unit Tests: ensure that image sizes are indeed removed when errors are raised before assertions in Tests_Media.
See #36588.


git-svn-id: https://develop.svn.wordpress.org/trunk@37328 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-29 17:51:54 +00:00
Scott Taylor
fe85e78329 Media/Unit Tests: ensure that the GD absrtraction is used for GD unit tests for Images. Some of the procedural GD API functions can still throw ImagickException, which is fun.
See #36588.


git-svn-id: https://develop.svn.wordpress.org/trunk@37327 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-29 16:15:37 +00:00
Boone Gorges
00c39a3f98 Query: Discard non-scalar 'm' instead of attempting to sanitize.
`WP_Query` discards most non-array date values ('year', 'monthnum', etc) by
casting to integer. Since [25138], the 'm' parameter has been handled
as a string; see #24884. However, the string-handling introduced in [25138]
blindly attempted to handle arrays and other non-scalar types as strings,
resulting in PHP notices and invalid MySQL syntax.

Props vortfu.
Fixes #36718.

git-svn-id: https://develop.svn.wordpress.org/trunk@37324 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-29 13:14:18 +00:00
Eric Andrew Lewis
878343d4d1 Database: Set MySQL connection collation.
Fixes #36649.


git-svn-id: https://develop.svn.wordpress.org/trunk@37320 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-28 01:38:31 +00:00
Eric Andrew Lewis
8692cdbecd Build/Test Tools: Document WP_UnitTestCase->go_to()
Fixes #36679.


git-svn-id: https://develop.svn.wordpress.org/trunk@37319 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-27 18:24:34 +00:00
Jeremy Felt
967eb06e1b Tests: Reduce unnecessary count in create_many() in multisite user tests
The tests for `is_blog_user()` and `is_user_member_of_blog()` should be refactored. Until then, we can shave several seconds from the test time by avoiding unnecessary loops of the same tests.

See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37318 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-27 06:32:47 +00:00
Jeremy Felt
534f0e92a0 Users: Provide a full user object when checking for a spammy multisite user
`is_user_spammy()` falls back to the current user if one is not provided. There is no current user during authentication, so the result is always `false`. Pass a user to fill the void.

Adds tests for `wp_authenticate_spam_check()`.

Props websupporter.
Fixes #36546.


git-svn-id: https://develop.svn.wordpress.org/trunk@37316 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-27 05:35:37 +00:00
Rachel Baker
1bee2ff07a Post Thumbnails: Fix logic bug and tests from [37308] where post-thumbnails support wasn’t added if there were no previous post_types with support already.
See #22080

git-svn-id: https://develop.svn.wordpress.org/trunk@37313 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-26 20:28:46 +00:00
Rachel Baker
3518df091f Tests: Fix typo current_theme_support() -> current_theme_supports() from [37308]
git-svn-id: https://develop.svn.wordpress.org/trunk@37309 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-26 17:30:19 +00:00
Rachel Baker
2ff19ab7d3 Post Thumbnails: When using add_theme_support( ‘post-thumbnails’, array( $post_types) ) merge the supported post_types.
Allow the adding of post-thumbnail support for one or more post_types without unsetting any previously added post_types. This matches the behavior of other uses of `add_theme_support()` and the expectations of a function with a prefix of “add”.
To unset post-thumbnail support use `remove_theme_support()` instead.

Fixes #22080

Props alexkingorg, jmichaelward, and flixos90.

git-svn-id: https://develop.svn.wordpress.org/trunk@37308 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-26 17:04:25 +00:00
Sergey Biryukov
274902b03a Build/Test Tools: Reset the PHPMailer mock in Tests_Mail::tearDown().
Props welcher.
Fixes #36609.

git-svn-id: https://develop.svn.wordpress.org/trunk@37307 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-23 08:15:11 +00:00
Scott Taylor
aba30dc390 Unit Tests: prevent rewrite spillage from @group author unit tests.
See #36587.


git-svn-id: https://develop.svn.wordpress.org/trunk@37306 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-22 23:47:27 +00:00
Scott Taylor
a776b0b6df Comments: add a $comment parameter to get_comment_author_url_link().
Add unit tests (none exist).

Props flixos90, wonderboymusic.
Fixes #36573.


git-svn-id: https://develop.svn.wordpress.org/trunk@37305 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-22 22:44:33 +00:00
Jeremy Felt
5af20a3de3 Tests: Account for flexible IDs in main network deletion test
After [37299], the network IDs encountered by this test may be larger than "100".

This adjusts the test to respond accordingly until we have a better way to delete networks.

See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37300 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-22 15:21:14 +00:00
Boone Gorges
7c79386135 Tests: Use the same incrementor for all fields belonging to a given text fixture.
[35244] changed the way that `WP_UnitTest_Generator_Sequence()` created an
incrementor for object fields (like 'post_name' and 'user_email'), by making
incrementor static across the entire run of the test suite. While this helped
to enforce uniqueness across the tests, it has the side effect of bumping the
incrementor between fields on the same object (so that, eg, the same post might
have `post_name` "post-12" but `post_title` "Post 13". By switching to a
technique that uses the same incrementor for each field belonging to a given
fixture, we conform better to the expectations of developers using
`WP_UnitTest_Factory`.

Fixes #35199.

git-svn-id: https://develop.svn.wordpress.org/trunk@37299 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-22 14:35:52 +00:00
Gary Pendergast
f9e1cf5de0 Smilies: Move convert_smilies to happen later in the the_content filter.
In particular, we want it to occur after shortcode handling. The smiley conversion routine doesn't have any concept of shortcode structure, so may inadvertantly replace a smiley with HTML inside a shortcode attribute, which will cause the shortcode to not be parsed correctly.

Props Unyson for the initial suggested fix.

Fixes #36306. 



git-svn-id: https://develop.svn.wordpress.org/trunk@37298 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-22 07:07:03 +00:00
Gary Pendergast
74e88010c0 Emoji: The :roll: smiley is now an emoji.
Unicode 8 added `U+1F644`, "Face with Rolling Eyes", which matches our `:roll:` smiley. Continuing our ever present quest to rid the world of legacy smilies, we now translate that smiley into its emoji form.

Sadly, `:mrgreen:` remains sorely under-represented in the Unicode standard, I'm inclined to think that we should buy a voting membership of the Unicode Consortium, in order to rectify that situation. (Personally, I'm hoping for a green skin tone modifier.)

Fixes #36365.
 



git-svn-id: https://develop.svn.wordpress.org/trunk@37296 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-22 06:28:51 +00:00
Dominik Schilling (ocean90)
153610292d Media: Remove an extra quote when sending a link of a media file to the editor.
Introduced in [37035].

Props joemcgill, swissspidy, boonebgorges.
Fixes #36578.

git-svn-id: https://develop.svn.wordpress.org/trunk@37288 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-21 21:20:26 +00:00
Boone Gorges
ce350d5d5d Tests: More explicit fixture content when testing s=0 query string.
After [36647], the unit test generator sequence can put a 0 into the
'post_excerpt' field of a post fixture, causing false positives.

See [36520] for a parallel fix involving 'post_content'.

Fixes #36622.

git-svn-id: https://develop.svn.wordpress.org/trunk@37280 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-21 15:52:33 +00:00
Sergey Biryukov
d5e795ca9e Users: Add a unit test for [37276].
See #36009.

git-svn-id: https://develop.svn.wordpress.org/trunk@37277 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-21 11:51:59 +00:00
Drew Jaynes
6c4c867b89 Tests: Pre-declare the $year_url property before initialization in Tests_Get_Archives::setUp().
Props pbearne.
Fixes #36611.


git-svn-id: https://develop.svn.wordpress.org/trunk@37271 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-21 02:55:52 +00:00
Jeremy Felt
67e6dc1c43 Tests: Add speedTrapListener to multisite's PHPUnit config
See #36566, #30017.


git-svn-id: https://develop.svn.wordpress.org/trunk@37267 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-20 17:01:07 +00:00
Jeremy Felt
f692459926 Tests: Allow override of MULTISITE and SUBDOMAIN_INSTALL constants
Props rmccue.
Fixes #36567.


git-svn-id: https://develop.svn.wordpress.org/trunk@37266 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-20 16:51:58 +00:00
Boone Gorges
01ef43ace7 Tests: After [37260], use WP's setUpBeforeClass() wrappers.
This ensures no leakage between tests of fixture IDs.

See #36602.

git-svn-id: https://develop.svn.wordpress.org/trunk@37261 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-20 15:30:40 +00:00
Boone Gorges
ddd88a79b1 Add tests for permastruct containing /%category%/.
See #36602.

git-svn-id: https://develop.svn.wordpress.org/trunk@37260 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-20 14:59:02 +00:00
Dominik Schilling (ocean90)
4bd7394a2e Themes: Revert [36112]
Adding the `singular` class per default to the list of body classes is breaking the layout of Twenty Eleven and other themes. Twenty Eleven adds the `.singular` class only to single pages if the page doesn't use specific page templates.

Props flixos90, swissspidy.
Fixes #36510.

git-svn-id: https://develop.svn.wordpress.org/trunk@37249 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-19 21:23:20 +00:00
Jeremy Felt
d72c2197ed Tests: Add test for multiple site path segments in bootstrap
This fixes a `@todo` that has been around since the introduction of these tests in [28910].

See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37241 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-18 03:38:11 +00:00
Jeremy Felt
fa92abf4f3 Tests: Add missing params to doc blocks
* These should have been included in [37236] and [37238].
* Simplifies parameter names in `test_get_network_by_path()`

See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37239 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-18 03:26:48 +00:00
Jeremy Felt
bf5abfd9d0 Tests: Use a data provider to test multisite's bootstrap
This also helps to get things in order before the introduction of a more testable multisite bootstrap function in #34941.

A `@todo` has been temporarily removed, to be re-introduced as a working test.

See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37238 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-18 03:18:51 +00:00
Jeremy Felt
5e2f936c28 Tests: Use a data provider in get_site_by_path() tests
See #36566, #34941.


git-svn-id: https://develop.svn.wordpress.org/trunk@37237 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-18 02:38:49 +00:00
Jeremy Felt
48ba391b9b Tests: Use a data provider to test get_network_by_path()
See #36566, #34941.


git-svn-id: https://develop.svn.wordpress.org/trunk@37236 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-18 02:00:36 +00:00
Jeremy Felt
e4efe5fac9 Tests: Share test fixtures in multisite bootstrap tests
* Remove unnecessary `setUp` and `tearDown` methods.
* Create networks and sites in `wpSetupBeforeClass` to share throughout.
* Destroy networks and sites in `wpTearDownAfterClass` to unpollute.

See #36566, #34941.


git-svn-id: https://develop.svn.wordpress.org/trunk@37234 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-18 01:37:47 +00:00
Jeremy Felt
89877c5941 Tests: Improve get_blog_count() tests
* Use `wp_update_network_counts()` to update the database with the most current data before testing.
* Use `wp_update_network_counts()` to update the database with the most current data after deleting the sites created during the test.
* Create only 1 extra site in each test rather than 4. This shaves several seconds off the test time.
* Stop testing for an extra count now that we update the network counts properly. Previously we looked at `$site_count_start + 9` rather than 8. Now this is `+ 1`, which aligns with the actual number of sites created.
* Test 3 explicit conditions - default, filter applied as `true`, and filter applied as `false`.
* Reset data before testing assertion to avoid a suspended state.

See #36566.


git-svn-id: https://develop.svn.wordpress.org/trunk@37233 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-18 01:28:56 +00:00
Boone Gorges
8ee26e699f Query: Allow results to be ordered by post_parent__in.
Props postpostmodern.
Fixes #36515.

git-svn-id: https://develop.svn.wordpress.org/trunk@37225 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-17 03:16:36 +00:00
Boone Gorges
d73ec171c0 Tests: Improvements to /post/query test class.
* Add `@group` annotation.
* Remove unnecessary `setUp()` method.

git-svn-id: https://develop.svn.wordpress.org/trunk@37224 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-17 03:12:39 +00:00
Jeremy Felt
426f5256fb Options: Do not set network options to autoload in single site
When multisite is not configured, the `_site_transient()` and `_site_option()` functions fallback to `_option()` and store network "meta/options" in `wp_options`.

Previously, those calls to `_option()` did not explicitly set the `autoload` parameter and anything assigned as a transient or option at the network level would be set to `autoload` by default, even though autoload is not yet a concept at the network option level.

This changes that behavior and forces the `autoload` setting to `no`. If `autoload` is desired, the single site option functions should be used.

Props thomaswm.
Fixes #22846.


git-svn-id: https://develop.svn.wordpress.org/trunk@37223 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-16 19:47:14 +00:00
Jeremy Felt
83d80f7329 Tests: Run network option tests as single and multisite
The `_network_option()` functions are available to all and
internally use `_option()` functions as a fallback. We should
be testing for that scenario as well.

Fixes #36552.


git-svn-id: https://develop.svn.wordpress.org/trunk@37222 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-16 19:21:49 +00:00
Jeremy Felt
a56fc1fba0 Multisite: Introduce WP_Theme methods to network enable/disable themes.
* `WP_Theme::network_enable_theme()` can be used to enable a theme or array of themes on a network.
* `WP_Theme::network_disable_theme()` can be used to disable a theme or array of themes on a network.
* Use these new methods in the network admin vs direct `update_site_option()` calls.
* Add tests.

Props igmoweb.
Fixes #30594.


git-svn-id: https://develop.svn.wordpress.org/trunk@37202 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-14 03:39:45 +00:00
Sergey Biryukov
c39ba1cdd9 Docs: Reference the correct variable in WP_Ajax_UnitTestCase::_handleAjax() documentation.
Props meitar.
Fixes #36522.

git-svn-id: https://develop.svn.wordpress.org/trunk@37199 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-14 02:28:03 +00:00
Boone Gorges
26a5e78d94 Improve testability and coverage of wp_ext2type().
* Following pattern of `wp_get_mime_types()`, introduce `wp_get_ext_types()` function. New function returns a filtered list of file types with their extensions.
* Use this function in new tests for `wp_ext2type()`.

Props borgesbruno.
Fixes #35987.

git-svn-id: https://develop.svn.wordpress.org/trunk@37189 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-13 03:11:25 +00:00
Boone Gorges
765e23a4a6 Use LEFT JOIN when building WP_Tax_Query SQL.
`LEFT JOIN` ensures that `NOT EXISTS` queries will not miss posts that have
no taxonomy data whatsoever.

Props swissspidy, crstauf.
Fixes #36343.

git-svn-id: https://develop.svn.wordpress.org/trunk@37184 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-12 20:36:31 +00:00
Jeremy Felt
f98744ec86 Ensure consistent dependency order when using wp_add_inline_script()
This disables the concatenation of remaining enqueued scripts once `wp_add_inline_script()` is invoked, which allows us to reliably print these scripts and their before/after inline scripts in the desired order.

Props gitlost, azaozz, swisspidy, ocean90.
Fixes #36392.


git-svn-id: https://develop.svn.wordpress.org/trunk@37171 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-10 03:32:47 +00:00
Dominik Schilling (ocean90)
ca5db69c31 Customize: Harden assignment of Customizer settings transports for selective refreshable widgets
Theme support for `customize-selective-refresh-widgets` can be added _after_ the logic for registering the settings for incoming widgets that have been changed. This is due to themes adding the theme support in `after_setup_theme` which is also the action where `WP_Customize_Widgets::register_settings()` is called. If these both happen at priority 10, which one is called first depends on which one was added first. The other issue is that at the time that `WP_Customize_Widgets::register_settings()` is called at `after_setup_theme`, it is called before `widgets_init` and thus no widgets are yet registered. This means that any settings registered at this point will always have a `refresh` transport even if the theme supports `customize-selective-refresh-widgets`, since the `WP_Widget` instance is not visible yet to see if it supports selective refresh.

The fix: Defer `WP_Customize_Widgets::register_settings()` from `after_setup_theme` to `widgets_init` at priority 95 when the widget objects have all been registered. Also, ensure that the preview filter for `sidebars_widgets` is added before the sidebars are iterated for adding the controls.

Props westonruter.
Fixes #36389.

git-svn-id: https://develop.svn.wordpress.org/trunk@37166 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-07 20:58:56 +00:00
boonebgorges
f1c3ec9010 Use __trashed suffix rather than -%trashed% for trashed post slugs.
Percent signs are reserved characters in URIs. As such, it was impossible for
plugins to route requests to trashed posts, as happens in bbPress. The new
`__trashed` suffix should be sufficiently unique.

Also adds a test that demonstrates that the `__trashed` suffix can be
appended to slugs that contain the suffix somewhere other than the end of
the string.

Props netweb, ericlewis.
Fixes #11863.

git-svn-id: https://develop.svn.wordpress.org/trunk@37165 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-07 19:21:02 +00:00
Mark Jaquith
9deec9e723 REST API: Deliver parameters unadulterated instead of slashed.
We goofed, and parameters accessed through the REST API's methods
were slashed (inconsistently, even). This unslashes the data, so
you get the un-messed-with data that was sent.

Props joehoyle.
Fixes #36419.

git-svn-id: https://develop.svn.wordpress.org/trunk@37163 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-06 21:01:11 +00:00
John Blackbourn
6c79b715bd Role/Capability: Add create_sites and delete_sites to the list of capabilities that are checked as part of the comporehensive roles and capabilities tests.
See #32394, #36413


git-svn-id: https://develop.svn.wordpress.org/trunk@37157 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-04 22:29:55 +00:00
Aaron Jorbin
253308253b Adjust unit tests to account for change in [37144]
git-svn-id: https://develop.svn.wordpress.org/trunk@37150 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-30 19:52:14 +00:00
Konstantin Obenland
ef53a0db39 Template: Remove $size reference from get_custom_logo().
Argument was removed in [37077] in favor of `with` and `height` arguments.

Props ocean90.
Fixes #36327.



git-svn-id: https://develop.svn.wordpress.org/trunk@37135 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-30 17:19:41 +00:00
Ella Iseulde Van Dorpe
859d40bd24 Editor: wptextpattern: add back inline tests
See [37024].
See #33300.


git-svn-id: https://develop.svn.wordpress.org/trunk@37080 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-25 13:30:10 +00:00
Sergey Biryukov
0058968499 Canonical / Query: Restore the is_404() check in wp_old_slug_redirect() which was removed in [34659].
This reverts part of [34659] due to excessive canonical problems it's caused in 4.4.x.

Remove the unit tests which are no longer supported.
This also removes the `is_feed()` code to avoid confusion - only pages & embeds will be redirected.

Merges [36280] and [36281] to trunk.

Props dd32.
See #21602, #35344.

git-svn-id: https://develop.svn.wordpress.org/trunk@37075 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-23 21:53:44 +00:00
Boone Gorges
8e317daa37 Tests: Ensure that the default wp_die() handler can handle a WP_Error object.
Props dd32, utkarshpatel.
Fixes #36166.

git-svn-id: https://develop.svn.wordpress.org/trunk@37071 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-23 19:00:38 +00:00
Dominik Schilling (ocean90)
6c0a66cf49 Users: In edit_user() check for a blank password when adding a user.
Props wesleye, gitlost, adamsilverstein.
Fixes #35715.

git-svn-id: https://develop.svn.wordpress.org/trunk@37059 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-22 23:06:29 +00:00
Rachel Baker
dab5c5daa7 XMLRPC: Unit tests left off [r37043]
See #35874.

Props redsweater, rachelbaker

git-svn-id: https://develop.svn.wordpress.org/trunk@37044 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-22 15:11:06 +00:00
Weston Ruter
4569f93d3e Customize: Require opt-in for selective refresh of widgets.
* Introduces `customize-selective-refresh-widgets` theme support feature and adds to themes.
* Introduces `customize_selective_refresh` arg for `WP_Widget::$widget_options` and adds to all core widgets.
* Remove `selective_refresh` from being a component that can be removed via `customize_loaded_components` filter.
* Add `WP_Customize_Widgets::get_selective_refreshable_widgets()` and `WP_Customize_Widgets::is_widget_selective_refreshable()`.
* Fix default `selector` for `Partial` instances.
* Implement and improve Masronry sidebar refresh logic in Twenty Thirteen and Twenty Fourteen, including preservation of initial widget position after refresh.
* Re-initialize ME.js when refreshing `Twenty_Fourteen_Ephemera_Widget`.

See #27355.
Fixes #35855.


git-svn-id: https://develop.svn.wordpress.org/trunk@37040 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-21 21:58:02 +00:00
Andrew Ozz
058a2f558d Media: fix erroneously inserting a rel attribute in get_image_send_to_editor(). Reverts most of [34259] and [34260] and adds a unit test.
Props joemcgill, azaozz.
Fixes #36084.

git-svn-id: https://develop.svn.wordpress.org/trunk@37035 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-18 20:04:19 +00:00
Andrew Ozz
33947e4ba6 Responsive Images: the src of the image has to be first in the srcset, because of a bug in iOS8. Update the unit tests to reflect the changes.
Props jaspermdegroot, joemcgill, azaozz.
Fixes #35030.

git-svn-id: https://develop.svn.wordpress.org/trunk@37034 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-18 19:44:50 +00:00
Rachel Baker
da45e59bbd REST API: Add home_url to API index to avoid confusion with site_url.
Confusion abound, the API index is the generic term `url` to display the `site_url`. New `home` key will display the `home_url` in the index as well.

Fixes #35647.

git-svn-id: https://develop.svn.wordpress.org/trunk@37031 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-17 19:15:57 +00:00
Sergey Biryukov
57646fb7ba TinyMCE: Adjust textpattern tests for the changes in [37023].
See #33300.

git-svn-id: https://develop.svn.wordpress.org/trunk@37024 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-17 00:46:26 +00:00
John Blackbourn
f1af2813d3 Media: When generating the base URL to be used in the srcset attribute, use an https scheme when the image base URL's host matches that of the current host, and the request is being served over HTTPS. This prevents mixed content warnings caused by http embedded media.
See #34945
Props joemcgill


git-svn-id: https://develop.svn.wordpress.org/trunk@37022 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-16 22:48:13 +00:00
Dominik Schilling (ocean90)
ab8ff0dee1 Responsive images: Skip images with a missing $image_meta['file'] value.
Props joemcgill.
See [37002].
Fixes #35480.

git-svn-id: https://develop.svn.wordpress.org/trunk@37018 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-16 17:47:41 +00:00
Andrew Ozz
1046806376 Responsive images: do not attempt to create srcset when the image meta is missing or corrupted.
Props overclokk, jaspermdegroot, joemcgill.
Fixes #35480.

git-svn-id: https://develop.svn.wordpress.org/trunk@37002 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-16 02:17:19 +00:00
Andrew Ozz
22e01b6274 TinyMCE: update to 4.3.8, changelog: https://www.tinymce.com/docs/changelog/#version438-march152016.
Fixes #36254.

git-svn-id: https://develop.svn.wordpress.org/trunk@37000 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-15 21:37:22 +00:00
Mike Schroder
eb0268dbe7 Media: Fix typo in test_image_preserves_alpha_on_rotate().
peserves -> preserves; introduced in [31040].

See #30596.

git-svn-id: https://develop.svn.wordpress.org/trunk@36998 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-15 03:50:40 +00:00
Gary Pendergast
8233227667 WPDB: Reset connection status variables when the connection is closed.
Fixes #36240.



git-svn-id: https://develop.svn.wordpress.org/trunk@36997 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-15 03:27:14 +00:00
Boone Gorges
9f05bf8ed9 Query: Ignore search terms consisting of a single dash.
Due to the "exclude" support added in WP 4.4, single dashes were being
converted to "NOT LIKE '%%'" clauses, causing all searches to fail.

Props RomSocial, swissspidy.
Fixes #36195.

git-svn-id: https://develop.svn.wordpress.org/trunk@36989 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-14 14:11:16 +00:00
Boone Gorges
0fdf0d4566 Improve error handling in get_categories().
When passed an invalid `'taxonomy'`, `get_terms()` will return a `WP_Error`
object. This object should not be blindly cast to an array. Instead, an empty
array should be returned, to indicate that no matching terms have been found.

Props virgodesign, sebastian.pisula.
Fixes #36227.

git-svn-id: https://develop.svn.wordpress.org/trunk@36988 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-14 13:52:14 +00:00
Boone Gorges
8b564b6106 Fix test related to cap check in get_edit_term_link().
The test was introduced in [36646] was intended to demonstrate that the cap
check in `get_edit_term_link()` uses the custom capability from the correct
taxonomy when `$taxonomy` is not specified but must be inferred from the
provided term. However, the test was wrongly written in pretty much every way.
Antiprops boonebgorges.

Props swissspidy.
See #35922.

git-svn-id: https://develop.svn.wordpress.org/trunk@36986 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-14 01:51:12 +00:00
John Blackbourn
93942d330e Correct a unit test for custom icon functionality.
See #36086


git-svn-id: https://develop.svn.wordpress.org/trunk@36952 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-10 19:58:49 +00:00
Konstantin Obenland
cda0901425 Template: Explicitly set full as the default custom logo size.
See #33755.


git-svn-id: https://develop.svn.wordpress.org/trunk@36950 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-10 19:02:25 +00:00
Konstantin Obenland
6f69ca857e Tests: Introduce multisite unit tests.
Makes sure custom logo functions work for other sites within a network.
Fixes a bug in `get_custom_logo()` where the correct logo was returned, but
linked to the wrong site.

H/t ocean90.
See #33755, #36086.


git-svn-id: https://develop.svn.wordpress.org/trunk@36949 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-10 18:56:56 +00:00
Konstantin Obenland
6d951b3c5d Customize: Only add custom logo’s header text control if needed.
Dissolves `WP_CustomLogo` and adopts a structure similar to custom header and background (See `_delete_attachment_theme_mod()`).
The option to hide header text only gets added if it’s not already part of custom header, and only if selectors have been registered when theme support for custom logos was declared. Themes can add `postMessage` support for it as well.

Example:
{{{
add_theme_support( 'custom-logo', array(
    'size' => ‘large’,
    'header-text' => array( 'site-title', 'site-description' ),
) );
}}}

See #33755.


git-svn-id: https://develop.svn.wordpress.org/trunk@36915 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-09 23:43:49 +00:00
Konstantin Obenland
4286a3e63b Tests: Let's not reinvent wp_get_attachment_image().
See https://travis-ci.org/aaronjorbin/develop.wordpress/builds/114913862
See #36086.


git-svn-id: https://develop.svn.wordpress.org/trunk@36914 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-09 23:27:28 +00:00