Commit Graph

56 Commits

Author SHA1 Message Date
rachelbaker bf6a689c65 REST API: Include the `status` property in `view` context responses from the Posts endpoints.
Previously the status for a Post (or other post_types) was only exposed under the `edit` context, which doesn't really make much sense considering we support querying by post status without authentication. Originally introduced in v2.0 beta 1: 69f617d749 without any explanation in the commit message.

Props dhanendran, jnylen0, rachelbaker.
Fixes #39466.


git-svn-id: https://develop.svn.wordpress.org/trunk@40080 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-19 04:31:12 +00:00
James Nylen 900c67ed46 REST API: Skip generating the client test fixtures in PHP 5.2 and 5.3.
Follow-up to [40065] - `JSON_*` constants are differently unsupported in PHP 5.2 and 5.3, which caused other, more different failures.

Also bring back `JSON_UNESCAPED_SLASHES` because the generated output looks nicer this way.

Fixes #39264.


git-svn-id: https://develop.svn.wordpress.org/trunk@40066 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-17 00:12:49 +00:00
James Nylen 9d96b31b90 REST API: Fix the client test fixture generation in PHP 5.2 and 5.3.
Remove `JSON_UNESCAPED_SLASHES` from the `wp_json_encode` call - this constant is not supported in PHP < 5.4, and we don't polyfill it either.

Also make the PHPUnit test suite correctly exit with a non-zero exit code when `wp-tests-config.php` is not present.  This was causing `grunt restapi-jsclient` to incorrectly proceed to its second step even when the first step failed with this error.

Props ocean90.
Fixes #39264.


git-svn-id: https://develop.svn.wordpress.org/trunk@40065 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-16 23:29:16 +00:00
Adam Silverstein e3d5e1c6c8 REST API: improve test fixture generation, normalizing data.
Add a data normalization pass when generating data fixtures for the REST API endpoints. Ensures that the `wp-api-generated.js` fixture won't change between test runs. Set more default properties and use fixed values for any properties that can't be easily controlled (object IDs and derivatives like link). Generate the fixture file with JSON_PRETTY_PRINT so that future diffs are easier to follow.

Props jnylen0, netweb.
Fixes #39264.


git-svn-id: https://develop.svn.wordpress.org/trunk@40061 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-15 17:58:14 +00:00
Adam Silverstein 2e0f576156 Media: debounce the media grid search, avoiding duplicate requests.
Add a debounce wrapper to the media grid search handler. The search callback is now fired after a 300 ms typing pause.

Remove redundant handlers for 'search' and 'change', preventing multiple/duplicate search callbacks.

Props certainstrings, joemcgill, Kelderic, batmoo.
Fixes #38911.


git-svn-id: https://develop.svn.wordpress.org/trunk@40060 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-15 17:28:54 +00:00
Adam Silverstein 1879140548 REST API: Add QUnit tests for wp-api.js and PHPUnit fixture generation.
Add QUnit tests: verify that wp-api loads correctly, verify that the expected base models and collections exist and can be instantiated, verify that collections contain the correct models, verify that expected helper functions are in place for each collection.

The QUnit tests rely on two fixture files: `tests/qunit/fixtures/wp-api-generated.js` contains the data response from each core endpoint and is generated by running the PHPUnit `restapi-jsclient` group. `tests/qunit/fixtures/wp-api.js` maps the generated data to endpoint routes, and overrides `Backbone.ajax` to mock the responses for the tests.

Add PHPUnit tests in `tests/phpunit/tests/rest-api/rest-schema-setup.php`. First, verify that the API returns the expected routes via `server->get_routes()`. Then, the `test_build_wp_api_client_fixtures` test goes thru each endpoint and requests it from the API, tests that it returns data, and builds up the data for the mocked QUnit tests, saving the final results to `tests/qunit/fixtures/wp-api-generated.js`.

Add a new grunt task `restapi-jsclient` which runs the phpunit side data generation and the qunit tests together.

Props jnylen0, welcher.
Fixes #39264.



git-svn-id: https://develop.svn.wordpress.org/trunk@40058 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-14 04:22:32 +00:00