Commit Graph

267 Commits

Author SHA1 Message Date
K. Adam White 22480c035b REST API: Add test class file incorrectly omitted from [45807].
Props @TimothyBlynJacobs.
See #43392.


git-svn-id: https://develop.svn.wordpress.org/trunk@45808 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 17:20:02 +00:00
K. Adam White c92ef7c441 REST API: Support 'object' and 'array' types in register_meta() schemas.
Extends meta registration to support complex schema values, mirroring the functionality in the settings controller.
Error when trying to modify a meta key containing schema-nonconformant data.

Props @TimothyBlynJacobs, @birgire, @mnelson4, @flixos90.
Fixes #43392.



git-svn-id: https://develop.svn.wordpress.org/trunk@45807 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 17:16:21 +00:00
Gary Pendergast 4271f1aeca Build Tools: Switch all Travis PHPUnit jobs over to Docker-based PHP.
Additionally, there are a handful of related minor changes in this commit:
- `.travis.yml` has been tidied up a little.
- [45745] was incorrectly marking Travis jobs as passed when some PHPUnit runs failed.
- Add the `LOCAL_PHP_MEMCACHED` environment variable, for enabling Memcached.
- Add the `env:pull` NPM script, for refreshing Docker images.

See #47767.


git-svn-id: https://develop.svn.wordpress.org/trunk@45762 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-07 11:54:22 +00:00
Gary Pendergast c6c78490e2 Coding Standards: Fix the remaining issues in `/tests`.
All PHP files in `/tests` now conform to the PHP coding standards, or have exceptions appropriately marked.

Travis now also runs `phpcs` on the `/tests` directory, any future changes to these files must conform entirely to the WordPress PHP coding standards. 🎉

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45607 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-08 00:55:20 +00:00
Gary Pendergast fe28df65e3 Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `tests`.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45588 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 04:43:01 +00:00
Gary Pendergast ef5a9dfda6 Coding Standards: Fix/ignore the `WordPress.NamingConventions.ValidFunctionName` violations.
See #47632



git-svn-id: https://develop.svn.wordpress.org/trunk@45580 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 08:00:12 +00:00
Sergey Biryukov af0c73b10b Build/Test Tools: Add `$current_screen` to the list of globals to unset in `WP_UnitTestCase_Base::go_to()`.
Props mauteri.
Fixes #47439.

git-svn-id: https://develop.svn.wordpress.org/trunk@45486 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-31 14:06:27 +00:00
John Blackbourn 814aa7149f Build/Test Tools: Remove the dependency on a globally installed Grunt.
The existing `"grunt": "grunt"` script in `package.json` allows for the use of `npm run grunt ...` which uses the local `grunt` binary in the project's `node_modules`.

Fixes #47380


git-svn-id: https://develop.svn.wordpress.org/trunk@45445 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-26 19:34:24 +00:00
Sergey Biryukov 10855438ea Date/Time: Replace all instances of `date()` with `gmdate()`.
Use of `date()` in core depends on PHP timezone set to UTC and not changed by third party code (which cannot be guaranteed).

`gmdate()` is functionally equivalent, but is not affected by PHP timezone setting: it's always UTC, which is the exact behavior the core needs.

Props nielsdeblaauw, Rarst.
Fixes #46438. See #44491.

git-svn-id: https://develop.svn.wordpress.org/trunk@45424 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-26 00:11:37 +00:00
John Blackbourn b64f812a59 Docs: Switch to the more common syntax for variadic function documentation.
See #37402


git-svn-id: https://develop.svn.wordpress.org/trunk@45418 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-25 21:58:18 +00:00
John Blackbourn dde307d4c9 Build/Test tools: Add some docs to the test functions.
Props andizer

Fixes #46501


git-svn-id: https://develop.svn.wordpress.org/trunk@45160 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-11 17:29:20 +00:00
Sergey Biryukov 368ea6bfc5 Build/Test Tools: Display an error message with a recommendation to run `grunt build` when trying to run WordPress core tests without the `/build/` directory.
Props davidbaumwald.
Fixes #46593.

git-svn-id: https://develop.svn.wordpress.org/trunk@45020 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-26 23:52:03 +00:00
Sergey Biryukov 65bd3654cc Privacy: Introduce Privacy Policy page helpers:
* `is_privacy_policy()` template tag
* `privacy-policy.php` template
* `.privacy-policy` body class
* `.menu-item-privacy-policy` menu item class

Props garrett-eclipse, birgire, xkon, Clorith.
Fixes #44005.

git-svn-id: https://develop.svn.wordpress.org/trunk@44966 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-21 19:47:29 +00:00
John Blackbourn 4b2a7d4ab6 Build/Test tools: Add support for passing a `WP_Error` object to `wp_die()` during tests.
This brings the functionality inline with `wp_die()` during non-test usage.

Fixes #46460


git-svn-id: https://develop.svn.wordpress.org/trunk@44944 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-20 18:22:11 +00:00
Sergey Biryukov 6d2f78d9ba Docs: Add missing article in `setExpectedDeprecated()` DocBlock.
See #46543.

git-svn-id: https://develop.svn.wordpress.org/trunk@44923 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-17 13:10:44 +00:00
Sergey Biryukov aaf266db42 Docs: Correct `@param` name in `setExpectedIncorrectUsage()` DocBlock.
Props yoavf.
Fixes #46546.

git-svn-id: https://develop.svn.wordpress.org/trunk@44922 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-17 12:22:10 +00:00
Sergey Biryukov 7be4aabff6 Coding Standards: Minor code and performance improvements in `phpunit/includes/abstract-testcase.php`.
Props andizer.
Fixes #46500.

git-svn-id: https://develop.svn.wordpress.org/trunk@44916 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 22:13:30 +00:00
Sergey Biryukov 98e2fcf4fc Build/Test Tools: Add missing access modifiers in `phpunit/includes/wp-profiler.php`.
Props andizer.
Fixes #46505.

git-svn-id: https://develop.svn.wordpress.org/trunk@44915 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 21:58:01 +00:00
Jonathan Desrosiers 152e9d2b8f Privacy: Add unit tests for exporting and erasing personal data.
Props birgire, garrett-eclipse, desrosj.
Fixes #43438.

git-svn-id: https://develop.svn.wordpress.org/trunk@44909 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 18:07:09 +00:00
Sergey Biryukov 04a9083709 PHPCS: Remove extra space added in [44902].
See #46499.

git-svn-id: https://develop.svn.wordpress.org/trunk@44904 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 14:27:07 +00:00
Sergey Biryukov 1bfa9370f7 Build/Test Tools: Add missing access modifiers to factory classes in `phpunit/includes/factory`.
Props andizer.
Fixes #46504.

git-svn-id: https://develop.svn.wordpress.org/trunk@44903 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 12:15:08 +00:00
Sergey Biryukov 981ed3fbc6 Docs: Improve documentation for `phpunit/includes/abstract-testcase.php`.
Props andizer.
Fixes #46499.

git-svn-id: https://develop.svn.wordpress.org/trunk@44902 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 12:01:15 +00:00
Jonathan Desrosiers a71fece6b8 Built/Test Tools: Add missing access modifiers to `abstract-testcase.php`.
Fixes #46384.
Props andizer.

git-svn-id: https://develop.svn.wordpress.org/trunk@44823 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-08 20:51:32 +00:00
Riad Benguella ccfb76d26f Block Editor: Fix unit tests after new blocks addition.
- Regenerate the REST API fixtures.
 - Remove the block registration hooks in the unit tests.

Refs #46429.


git-svn-id: https://develop.svn.wordpress.org/trunk@44812 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-07 11:53:15 +00:00
Aaron Jorbin e421f262dc Replace usages of basename() with wp_basename() in order to support multibyte filenames
This is focused on the pieces of code that touch media files and the tests that support them. `basename` isn't multibyte compatible out of the box. See http://php.net/basename and https://bugs.php.net/bug.php?id=62119.

See #43170.
Props Viper007Bond.


git-svn-id: https://develop.svn.wordpress.org/trunk@44785 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-01 20:57:26 +00:00
Sergey Biryukov 3e19129dc9 Build/Test Tools: Display a message about currently supported PHPUnit branch to avoid fatal errors on later versions.
See #46149.

git-svn-id: https://develop.svn.wordpress.org/trunk@44723 602fd350-edb4-49c9-b593-d223f7449a82
2019-02-03 22:40:56 +00:00
Sergey Biryukov 4b8e33fbee Build/Test Tools: Move `WP_UnitTestCase_Base::assertPostConditions()` to a more appropriate place.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44719 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-30 14:30:42 +00:00
Sergey Biryukov b9b66b159b Build/Test Tools: Simplify `WP_PHPUnit_Util_Getopt` and update documentation.
Introduced in [918/tests] and updated in [26871], the class is there to make sure that known bugs are not skipped when `phpunit` is called with a `--group` that corresponds to an `@ticket` annotation (such as `phpunit --group 12345`).

Enforcing recognized arguments or correctly formed arguments is not the concern here, so reusing `PHPUnit_Util_Getopt::parseLongOption()` was superfluous.

See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44715 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-30 00:53:52 +00:00
Sergey Biryukov 6e80f7cebf Build/Test Tools: Don't throw an exception for unrecognized options in `WP_PHPUnit_Util_Getopt::parseLongOption()`.
The method is only used for two known options: `group` and `exclude-group`, others should be passed to PHPUnit.

Props johnbillion.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44707 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 18:49:22 +00:00
Sergey Biryukov 001c6498e8 Build/Test Tools: Add support for PHPUnit 7.x.
* Create an abstract `WP_UnitTestCase_Base` class to share between PHPUnit 7.x and older versions.
* Add a speed-trap loader to determine which `SpeedTrapListener` class needs to be loaded for the current PHPUnit version.
* Remove unnecessary `PHPUnit\Util\Test` and `PHPUnit_Util_Getopt` inheritances.
* Update Travis CI config to use PHPUnit 7.x for PHP 7.1, 7.2, and nightly PHP versions.

Props jipmoors, netweb, desrosj, ayeshrajans, soulseekah, SergeyBiryukov.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44701 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 14:10:24 +00:00
Gary Pendergast 2e63f69564 Tests: Ensure meta keys are cleaned up after each test.
Props jnylen0.
Fixes #46007.



git-svn-id: https://develop.svn.wordpress.org/trunk@44633 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-17 04:33:42 +00:00
Gary Pendergast 65f5fcb0fb Coding Standards: Ignore the single WordPress.PHP.RestrictedPHPFunctions.create_function_create_function violation.
This is intentional, for older PHP support.

See #45934.


git-svn-id: https://develop.svn.wordpress.org/trunk@44560 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-11 03:44:20 +00:00
Gary Pendergast 0394aab7a8 Tests: Add support for a `WP_TESTS_SKIP_INSTALL` environment variable.
Defining `WP_TESTS_SKIP_INSTALL=1` when running tests will skip the install step. While this shouldn't be used for full test runs, it's useful for saving time when running small groups of tests.

Props soulseekah.
Fixes #43432.



git-svn-id: https://develop.svn.wordpress.org/trunk@44536 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 02:18:19 +00:00
Gary Pendergast e88eb4a63f Build/Tests: Allow running unit tests from `src`.
This is a partial recommit of [44509]: it allows running unit tests from `src` (which is useful), but doesn't make it the default (which Travis is having issues with).

See #45863.



git-svn-id: https://develop.svn.wordpress.org/trunk@44534 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 02:03:25 +00:00
Gary Pendergast 916695bd78 Tests: Revert [44509].
This commit causes Travis to fail.

See #45863.


git-svn-id: https://develop.svn.wordpress.org/trunk@44512 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 11:13:03 +00:00
Gary Pendergast 0137c23f8d Build/Tests: Default to running unit tests from `src`.
This is the actual commit, unlike [44508], which was not.

Props atimmer.
See #44492.
Fixes #45863.


git-svn-id: https://develop.svn.wordpress.org/trunk@44509 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 10:13:13 +00:00
Gary Pendergast ae62335191 Docs: Add docblocks for the PHPUnit factory objects.
Props andizer.
Fixes #44521.


git-svn-id: https://develop.svn.wordpress.org/trunk@44497 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 05:43:14 +00:00
Drew Jaynes 5e3c64657a Docs: Remove references to the now-defunct `$merged_filters` global from two method DocBlocks in `WP_UnitTestCase`.
The `$merged_filters` global was removed in [38571].

Props frank-klein.
Fixes #44496.


git-svn-id: https://develop.svn.wordpress.org/trunk@44327 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-19 07:12:46 +00:00
Jonathan Desrosiers 93091fac36 Blocks: Parse blocks when displaying posts.
Posts containing blocks are now correctly handled when displaying on the front end, including dynamic blocks and nested blocks.

Props pento.

Merges [43752] to trunk.

See #45109.

git-svn-id: https://develop.svn.wordpress.org/trunk@44118 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 18:11:10 +00:00
Gary Pendergast 9254ae4a72 Blocks: Introduce `WP_Block_Type` and `WP_Block_Type_Registry` classes.
These are the foundational classes allowing blocks to be registered and used throughout WordPress.

This commit also includes the `has_block()` and `has_blocks()` functions, which are required for unit testing these classes.

Merges [43742] from the 5.0 branch to trunk.

Props adamsilverstein, danielbachhuber, desrosj.
Fixes #45097.
See #45109.


git-svn-id: https://develop.svn.wordpress.org/trunk@44108 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 09:43:29 +00:00
Gary Pendergast 5c9c54239d REST API: Introduce controller for searching across post types.
Introduces a `WP_REST_Search_Controller` class which registers a `/wp/v2/search` endpoint. Search types are handled by extending `WP_REST_Search_Handler`. The default search type is `WP_REST_Post_Search_Handler` but can be filtered by plugins or a theme.

Merges [43739,43741] from the 5.0 branch to trunk.

Props danielbachhuber, flixos90, pento, rmccue, joehoyle.
Fixes #39965.



git-svn-id: https://develop.svn.wordpress.org/trunk@44107 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 09:37:05 +00:00
Jeremy Felt 894a8e02d2 REST API: Include permalink_template/generated_slug for Posts
In order for clients to present permalink previews, the REST API must share the computed results of get_sample_permalink(). These two values are now exposed as permalink_template and generated_slug for public, viewable post types, but only for context=edit.

Merges [43720] to trunk.

Props danielbachhuber, rahulsprajapati.
Fixes #45017.


git-svn-id: https://develop.svn.wordpress.org/trunk@43980 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-12 02:11:22 +00:00
Aaron Jorbin 6604782cd9 General: PHP7.3 throws an `E_WARNING` when using continue to target a switch
Applying continue to a switch is equivalent to using break and quite possibly, a continue targeting a higher level control structure is actually intended.

To target the higher level control structure, a numeric argument has to be passed to continue. This fixes two cases in WordPress Core where this is currently happening.

See: https://github.com/php/php-src/pull/3364
See: https://wiki.php.net/rfc/continue_on_switch_deprecation

Props jrf.
Fixes #44543.



git-svn-id: https://develop.svn.wordpress.org/trunk@43653 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-23 22:49:02 +00:00
Gary Pendergast a75d153eee Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.



git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-17 01:50:26 +00:00
Sergey Biryukov 4ce3db3e8d Build/Test Tools: Add documentation for `tests_add_filter()`, `_test_filter_build_unique_id()`, `_delete_all_data()`, `_delete_all_posts()`.
Props andizer.
Fixes #44703.

git-svn-id: https://develop.svn.wordpress.org/trunk@43555 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-02 22:35:10 +00:00
John Blackbourn 1e88432e34 Build/Test Tools: Introduce support for a `WP_TESTS_CONFIG_FILE_PATH` constant to override the test suite config file location.
This can be used in phpunit.xml:

{{{
<php>
	<const name="WP_TESTS_CONFIG_FILE_PATH" value="/path/to/wp-tests-config.php" />
</php>
}}}

Props clarinetlord

Fixes #39734


git-svn-id: https://develop.svn.wordpress.org/trunk@43369 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-16 14:21:18 +00:00
John Blackbourn 58a71dc610 Build/Test Tools: Allow the unit test framework to be used without the data directory in place.
Fixes #43982

git-svn-id: https://develop.svn.wordpress.org/trunk@43315 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-25 22:42:11 +00:00
John Blackbourn f4fbba188d Build/Test Tools: Roses are red, this fixes stuff.
Update the test infrastructure so that third party plugins, themes, and projects that use the core testing framework continue to operate from the `src` directory and do not require a build step.

Props mboynes, danielbachhuber, schlessera

See #43055


git-svn-id: https://develop.svn.wordpress.org/trunk@43311 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-23 17:54:44 +00:00
Gary Pendergast ef37f002ee Once upon a midnight dreary, while I coded, weak and weary,
In many a strange and curious file of forgotten lore—
While I pondered, blaming Nacin, my notifications suddenly awakened,
As of someone quietly DMing;—DMing me, I can’t ignore.
“’Tis some contributor,” I muttered, “DMing me an idea or four—
            Only this and nothing more.”

Ah, distinctly I remember, at WordCamp US, last December;
A mad proposal nearly laid me—down out cold—upon the floor.
Curious, I listened closely;—to a plan I agreed with, mostly—
A way to make our JavaScript—JavaScript which was a chore—
Maintainable, extendable, for the future, is what I saw.
            Guten-ready for evermore.

Open here I switch to Slack, when, with many a patch and hack,
In there stepped Omar, a JavaScript developer hardcore;
Pronouncing all the changes fit; ready now to be commit;
“There’s nothing else for us to do,” DMing me, “It’s done!” he swore—
“No longer random guessing at which file need next be explored—
            Let’s move on, we’re all aboard.”

Moved all together, grouped and managed, in folders all is packaged,
The code had all been cleaned and tidied, important parts moved to the fore,
“Though this change be useful here,” I said, “it is too large, I fear,
We couldn’t manage such a patch, we’ve done nothing like this before—
Tell me where doth go this change, change to make our codebase soar!”
            Quoth Omar, “In WordPress Core.”

Props omarreis for shepherding this significant change.
Props adamsilverstein, aduth, atimmer, dingo_bastard, frank-klein, gziolo, herregroen, jaswrks, jeremyfelt, jipmoors, jorbin, netweb, ocean90, pento, tjnowell, and youknowriad for testing, feedback, discussion, encouragement, commiserations, etc.
I make no apologies for this commit message.
Fixes #43055.



git-svn-id: https://develop.svn.wordpress.org/trunk@43309 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-23 10:04:22 +00:00
Felix Arntz 79bf20d320 Tests: Skip multisite-only or single site-only tests correctly based on test doc annotations.
Without the `ms-required` and `ms-excluded` groups being marked as excluded in the PHPUnit configurations for the project, those groups were still executed, causing fatal errors. Checking against the groups in the correct structure of the array returned from PHPUnit's `Testcase::getAnnotations()` ensures that those tests are skipped properly.

Fixes #43863.


git-svn-id: https://develop.svn.wordpress.org/trunk@43005 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-25 22:37:08 +00:00