In [36347] we moved all PHP factory classes into their own files except the main class. The main class is now in its own file, and `factory.php` is solely an include manifest for all factory classes.
git-svn-id: https://develop.svn.wordpress.org/trunk@36409 602fd350-edb4-49c9-b593-d223f7449a82
This makes the code easier to browse.
`factory.php` loads the new files, so this is backwards compatible in case `factory.php` is loaded directly for access to one of the classes.
See #35492.
git-svn-id: https://develop.svn.wordpress.org/trunk@36347 602fd350-edb4-49c9-b593-d223f7449a82
Added hardcoded maxlength attributes on the author, author_email, author_url, and comment_field input markup. These can be modified via the comment_form_defaults filter. Added logic in wp_handle_comment_submission() to return a WP_Error when the comment_author, comment_author_url, or comment_content values exceed the max length of their columns. Introduces wp_get_comment_column_max_length() which returns the max column length for a given column name, and is filterable. Unit tests included for the error conditions in wp_handle_comment_submission()
Fixes#10377.
Props westonruter rachelbaker.
git-svn-id: https://develop.svn.wordpress.org/trunk@36272 602fd350-edb4-49c9-b593-d223f7449a82
In MySQL 5.5.3, `storage_engine` was deprecated in favour of `default_storage_engine`, and subsequently removed in MySQL 5.7. To avoid errors when running tests on MySQL 5.7, we need to switch between the options based on MySQL version.
Props skithund, jeremyfelt.
Fixes#34692.
git-svn-id: https://develop.svn.wordpress.org/trunk@36055 602fd350-edb4-49c9-b593-d223f7449a82
This hardens WordPress against a common vector which uses multiple user identifiers in a single `system.multicall` call. In the event that authentication fails, all following authentication attempts ''in that call'' will also fail.
Props dd32, johnbillion.
Fixes#34336
git-svn-id: https://develop.svn.wordpress.org/trunk@35366 602fd350-edb4-49c9-b593-d223f7449a82
[34247] made the 'public' paramater of `register_taxonomy()` work by blocking
requests for non-public taxonomy archives during `parse_request()`. Blocking
taxonomy archive requests this late means that it's impossible to register an
independent query var that matches the slug of a non-public taxonomy. By
moving the block to `register_taxonomy()` - not allowing these taxonomies to
register their query vars in the first place - we free up the slug for other
use. In addition, we free up a bit of processing (no need to look for the query
var in `parse_request()` and better parallel the way non-public post types
work. See `register_post_type()`.
Non-public taxonomy archives that are requested using `?taxonomy=tax_name` are
still blocked during `parse_request`. It's only custom query vars -
`?tax_name=term` - that are affected by this change.
Props mboynes.
Fixes#21949.
git-svn-id: https://develop.svn.wordpress.org/trunk@35333 602fd350-edb4-49c9-b593-d223f7449a82
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
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
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
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
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
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
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
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
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
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
* 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
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
* 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
Continuing with the "code is poetry" theme after [34719], we need to continue
to update the option in the database on non-multisite in this
`wp_insert_term()` test.
See #31130.
git-svn-id: https://develop.svn.wordpress.org/trunk@34720 602fd350-edb4-49c9-b593-d223f7449a82
[34718] introduced a 'db_version' check to term meta functions, to ensure that
they don't run when the term meta schema is not yet in place. This call to
`get_option()` causes a database hit during Multisite tests, due to the
presence of the `WP_INSTALLING` constant. See #31130. The extra database
queries are causing cache tests to fail.
In similar cases, we have `markTestSkipped()` when `is_multisite()`. Because
the term meta API is so extensive - term meta caches can be primed anywhere a
`WP_Query` loop is fired up - we implement a more generous workaround in this
case. To prevent `get_option( 'db_version' )` from hitting the database during
multisite unit tests, we use a 'pre_option_' filter.
Heaven help us.
See #34091.
git-svn-id: https://develop.svn.wordpress.org/trunk@34719 602fd350-edb4-49c9-b593-d223f7449a82
Previously, we'd run the sanity checks if `is_mysql` was not set to `false`. This caused problems for DB drop-ins that didn't define `is_mysql` at all. Instead, we can just check if `is_mysql` is `empty()`.
Also fix some unit tests that accidently ran correctly because of the strict `false ===` comparison.
Fixes#33501.
git-svn-id: https://develop.svn.wordpress.org/trunk@34655 602fd350-edb4-49c9-b593-d223f7449a82
In `_unregister_post_type()` (unit tests), don't add query vars of non-viewable post types to `WP::public_query_vars`.
Adds unit test.
Fixes#30018.
git-svn-id: https://develop.svn.wordpress.org/trunk@34215 602fd350-edb4-49c9-b593-d223f7449a82
Includes two modifications for WordPress:
* Removes support for NTLM in `class-smtp.php` since the required client (`extras/ntlm_sasl_client.php`) is not distributed as part of WordPress.
* Requires `class-smtp.php` for backwards compatibility with direct (non-wp_mail()) uses of PHPMailer, as the autoloader isn't used. See [27385].
This also includes a change to our `MockMailer` for unit tests. It now overrides `postSend() instead of `send()`, and `preSend()`.
`preSend()` resets `$this->Encoding` because PHPMailer doesn't clean up after itself / presets all variables. This becomes an issue when `PHPMailer::createBody()` sets `$this->Encoding = 'quoted-printable'` (away from it's default of 8bit) when it encounters a line longer than 998 characters. `Tests_Comment::test_comment_field_lengths` is such a case.
props MattyRob, dd32.
fixes#28909.
git-svn-id: https://develop.svn.wordpress.org/trunk@33124 602fd350-edb4-49c9-b593-d223f7449a82
If you are subclassing these classes in your own tests, you'll need to update your code.
Props johnbillion
See #31982
git-svn-id: https://develop.svn.wordpress.org/trunk@33123 602fd350-edb4-49c9-b593-d223f7449a82
PHP7 is deprecating PHP4 style constructors, so we need to modify our code to have _construct methods that fire before the named PHP4 style constructors. The PHP4 style constructors will call the PHP5 style constructor in case it is being called directly (usually via parent::METHOD).
This modifies external libraries to add PHP5 style constructors, but doesn't add a notice for when they are used. In WordPress core code, PHP4 style constructors are being given a call to _deprecated_constructor. To the PHP4 style constructor I say "I know that I can't take no more | It ain't no lie | I wanna see you out that door | Baby, bye, bye, bye..."
Upstream: https://wiki.php.net/rfc/remove_php4_constructors
Props jdgrimes, netweb, jorbin
See #31982
git-svn-id: https://develop.svn.wordpress.org/trunk@32990 602fd350-edb4-49c9-b593-d223f7449a82
This eliminates PHP notices when `wp_mail()` needs to determine its own From header.
See [25381] for a previous fix, which focused only on the mail-specific tests.
Fixes#32702.
git-svn-id: https://develop.svn.wordpress.org/trunk@32839 602fd350-edb4-49c9-b593-d223f7449a82
The override is necessary because the `get_term()` call, which fetches the
term object, needs the `'taxonomy'` argument passed to the factory method.
Props dlh.
Fixes#32536.
git-svn-id: https://develop.svn.wordpress.org/trunk@32659 602fd350-edb4-49c9-b593-d223f7449a82
The unit tests expect non-pretty permalinks, so there's no benefit to detecting
the ability to have pretty permalinks. Moreover, the `wp_remote_get()` call can
cause installation to hang when there are DNS issues.
Fixes#31994.
git-svn-id: https://develop.svn.wordpress.org/trunk@32139 602fd350-edb4-49c9-b593-d223f7449a82
Failure to set this variable meant that passing the home URL to `go_to()`
(without a trailing slash) resulted in a PHP notice, and failed to reset the
globals properly.
Props joostdevalk.
Fixes#31417.
git-svn-id: https://develop.svn.wordpress.org/trunk@31515 602fd350-edb4-49c9-b593-d223f7449a82
* Do the `expectedDeprecated()` check in `assertPostConditions()` instead of `tearDown()`. Previously, `fail`ing inside of `tearDown()` was causing the rest of the teardown process to be aborted, resulting in inter-test leakage.
* Collect all `expectedDeprecated` and `expectedIncorrectUsage` annotations in an entire method and display them all when `fail`ing, instead of showing only the first one.
Props jdgrimes.
Fixes#31362.
git-svn-id: https://develop.svn.wordpress.org/trunk@31469 602fd350-edb4-49c9-b593-d223f7449a82
These methods provide a procedural alternative to the `@expectedDeprecated`
and `@expectedIncorrectUsage` test annotations, and parallel PHPUnit's native
`setExpectedException()`.
Props prasoon2211, jdgrimes.
Fixes#28486.
git-svn-id: https://develop.svn.wordpress.org/trunk@31306 602fd350-edb4-49c9-b593-d223f7449a82
Examples: if you clean up directories in a test, or a test fails before the directories are cleaned, or a test fails before the `'upload_path'` option is reset, the next call to `wp_upload_dir()` will recreate the directories you just tried to delete.
These changes ensure that `src/foo` and `/tmp/wp-unit-test` directories are deleted immediately after `wp_upload_dir()` is fired in the tests.
Fixes#30513.
git-svn-id: https://develop.svn.wordpress.org/trunk@30658 602fd350-edb4-49c9-b593-d223f7449a82
It should be defined in a common library file so that all tests have access to
it, even when run in isolation.
See [30345], #21212.
git-svn-id: https://develop.svn.wordpress.org/trunk@30528 602fd350-edb4-49c9-b593-d223f7449a82
In general, skipped tests should live only in patches, which are committed at
the same time that the corresponding bug is fixed. In cases where it's
necessary to skip a test, use `markTestSkipped()` to declare this fact
explicitly.
We continue to check Trac when using `WP_UnitTestCase` to run non-core tests.
See #30284.
git-svn-id: https://develop.svn.wordpress.org/trunk@30526 602fd350-edb4-49c9-b593-d223f7449a82
microtime is by default a string. Doing a greater then or less than check of that string is a bad idea since it uses the first part (the micro part of microtime) rather then the actual time. This adds a helper to convert microtime output into a float which we can then use to properly compare the output of microtime.
This fixes an intermittent test failure.
fixes#30336
git-svn-id: https://develop.svn.wordpress.org/trunk@30337 602fd350-edb4-49c9-b593-d223f7449a82
The external-http tests are very slow, and `Wp_Http` functionality is fairly
isolated, so the benefits of skipping these tests by default outweigh the
risks.
A `grunt phpunit:external-http` subtask has been added, to ensure that the
tests are executed during exhaustive runs of the test suite, such as in
continuous integration.
Fixes#30304.
git-svn-id: https://develop.svn.wordpress.org/trunk@30298 602fd350-edb4-49c9-b593-d223f7449a82
When the `ms_files_rewriting` flag is enabled, `ms_upload_constants()` is required to properly set upload directory constants. Once this fires, it is impossible to clean up for a non `ms_files_rewriting` test by turning the option back off.
Excluding these tests by default offer a more consistent environment overall. Any tests written for uploaded files in multisite should ideally have a correspondign test in this area.
This commit also moves existing `ms_files_rewriting` tests for `test_switch_upload_dir()`.
Fixes#30256
git-svn-id: https://develop.svn.wordpress.org/trunk@30286 602fd350-edb4-49c9-b593-d223f7449a82
`wp_delete_user()` doesn't remove the user from the database, which causes all
sorts of problems in certain cases.
Props jeremyfelt.
See [30277], #30017.
git-svn-id: https://develop.svn.wordpress.org/trunk@30278 602fd350-edb4-49c9-b593-d223f7449a82
Sharing these fixtures results in a speed improvement of almost one minute per
run of the test suite.
My hope is that future WordPress developers will spend this extra minute with
their loved ones, for life on this earth is short, my friends, and the moments
you spend watching WP generate test data can never again be reclaimed from the
grizzled clutches of Time, and none of us are really getting younger, I mean,
geez, have you looked in the mirror lately, Gandalf?
See #30017.
git-svn-id: https://develop.svn.wordpress.org/trunk@30277 602fd350-edb4-49c9-b593-d223f7449a82
Most of our unit tests that involve permalinks expect non-pretty permalinks;
this is the default setting for WP. However, when the test suite installs
multisite, `populate_network()` is run before WP recogizes itself as multisite,
which leads to pretty permalinks being set. This breaks a number of unit
tests in ways that are difficult to trace.
git-svn-id: https://develop.svn.wordpress.org/trunk@30267 602fd350-edb4-49c9-b593-d223f7449a82
This prevents $current_user, $userdata, and other user-related globals from
being polluted if a previous test does not properly reset the current user.
Props nacin, mnelson4.
Fixes#29712.
git-svn-id: https://develop.svn.wordpress.org/trunk@30001 602fd350-edb4-49c9-b593-d223f7449a82
A growing number of plugins and other WP-based projects use the core test
tools, such as WP_UnitTestCase, as the basis of their own tests and continuous
integration setups. At the same time, many of these third-party plugins use
custom post types and taxonomies, which are generally registered a single time
during a run of the tests: at 'init', before the testcases have run. Wiping out
these globals between tests will mess with these third-party builds.
Best practice for plugin developers is probably to clean up their own post types
and taxonomies and then reinitialize before each test. But, in the interest of
not breaking everyone's builds, the core test suite will not enforce this.
Fixes#29827.
git-svn-id: https://develop.svn.wordpress.org/trunk@29869 602fd350-edb4-49c9-b593-d223f7449a82
Registering a post type or taxonomy during a unit test causes modifications to
global variables. If the test fails to clean up these globals - either by
neglecting to call _unregister_post_type()/_unregister_taxonomy() at all or by
failing before getting a chance to do so - tests that run later in the suite
can fail, leading to much gnashing of teeth. Wiping all taxonomies and
restoring to the defaults before each test ensures that we always start with a
clean slate.
Fixes#29827.
git-svn-id: https://develop.svn.wordpress.org/trunk@29860 602fd350-edb4-49c9-b593-d223f7449a82
Add `WP_TESTS_TABLE_PREFIX` in `bootstrap.php` to ensure the original value for `$table_prefix` is always available.
Props jeremyfelt.
Fixes#28692.
git-svn-id: https://develop.svn.wordpress.org/trunk@28943 602fd350-edb4-49c9-b593-d223f7449a82
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
git-svn-id: https://develop.svn.wordpress.org/trunk@28493 602fd350-edb4-49c9-b593-d223f7449a82
Includes two trivial modifications for WordPress:
* Doesn't use the autoloader, so the check to enforce the autoloader from the constructor is removed.
* Requires class-smtp.php for backwards compatibility with direct (non-wp_mail()) uses of PHPMailer, as the autoloader isn't used.
props bpetty.
fixes#25560.
git-svn-id: https://develop.svn.wordpress.org/trunk@27385 602fd350-edb4-49c9-b593-d223f7449a82
Tries to get network detection under control by simplifying wpmu_current_site(). It now also pops off each subdomain to find a more general match. Adds unit tests for get_network_by_path() and a new network factory for unit tests.
Much of this is likely to change in 3.9 as more of ms-load.php and ms-settings.php gets hacked to bits.
props jeremyfelt.
see #27003.
git-svn-id: https://develop.svn.wordpress.org/trunk@27178 602fd350-edb4-49c9-b593-d223f7449a82
There are a few places in core that were preventing this from working by explicity setting `$wpdb->suppress_errors` to `false`. Instead, they should inherit the value that existed before errors were suppressed.
This allows Multisite unit tests to run without explosive database errors, and allows `$wpdb->suppress_errors` to be overridden all the way down the chain.
Fixes#26102.
git-svn-id: https://develop.svn.wordpress.org/trunk@26252 602fd350-edb4-49c9-b593-d223f7449a82
* `wp_ajax_get_comments()` relies on the `$post_id` global - even though `$_POST['p']` is passed to every action in the test methods. If `$post_id` is still lingering in between tests and doesn't match `p` in the request, the cap check might pass while the queries for comments will blow up. I added `unset( $GLOBALS['post_id'] )` to `Tests_Ajax_GetComments::setUp()`.
* If the global `$post_id` is empty, but `$_REQUEST['p']` is not, `$post_id` is now set to `absint( $_REQUEST['p'] )` and sanity-checked in `wp_ajax_get_comments()`.
* `map_meta_cap()` always assumes that `get_comment()` succeeds when checking for the `edit_comment` cap. It doesn't. I added sanity checks in a few places where it will break early if `get_post()` or `get_comment()` are empty.
* `wp_update_comment()` always assumes `get_comment()` succeeds. It doesn't. I added a check for empty.
All AJAX unit tests run and pass in debug mode. All general unit tests pass against these changes.
Fixes#25282.
git-svn-id: https://develop.svn.wordpress.org/trunk@25438 602fd350-edb4-49c9-b593-d223f7449a82
It works for both functions and arguments (using the value of the first argument passed to _deprecated_function() or _deprecated_argument(), which is typically the function name). It asserts both ways:
* If specified, those deprecated notices must be caught, or the test fails.
* If not specified, any other deprecated notices cause the test to fail.
Works regardless of WP_DEBUG.
see #25282.
git-svn-id: https://develop.svn.wordpress.org/trunk@25408 602fd350-edb4-49c9-b593-d223f7449a82
* Remove duplicated code for deprecated function notice suppression
* Add support in `WP_UnitTestCase` setUp/tearDown methods for `$deprecated_functions` fixture if the extending class has added it
* Add a `$deprecated_functions` fixture to each extending class that needs it
To use this fixture, add something to your Test Case class like so:
`protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' );`
See #25282.
git-svn-id: https://develop.svn.wordpress.org/trunk@25402 602fd350-edb4-49c9-b593-d223f7449a82
* Suppress deprecated function notice for `wp_load_image()`.
* Add assertion for `wp_get_image_editor()`.
See #25282.
git-svn-id: https://develop.svn.wordpress.org/trunk@25380 602fd350-edb4-49c9-b593-d223f7449a82
wp-tests-config.php can/should reside in the root of a develop checkout. `phpunit` should be run from the root.
see #25088.
git-svn-id: https://develop.svn.wordpress.org/trunk@25165 602fd350-edb4-49c9-b593-d223f7449a82