[wp-trac] [WordPress Trac] #39264: Add WP-API JS Client unit tests to core

WordPress Trac noreply at wordpress.org
Tue Feb 14 04:22:34 UTC 2017


#39264: Add WP-API JS Client unit tests to core
---------------------------------------------+-----------------------------
 Reporter:  adamsilverstein                  |       Owner:
     Type:  enhancement                      |  adamsilverstein
 Priority:  normal                           |      Status:  closed
Component:  REST API                         |   Milestone:  4.7.3
 Severity:  normal                           |     Version:  4.7
 Keywords:  has-patch has-unit-tests commit  |  Resolution:  fixed
                                             |     Focuses:  javascript
---------------------------------------------+-----------------------------
Changes (by adamsilverstein):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"40058"]:
 {{{
 #!CommitTicketReference repository="" revision="40058"
 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.
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39264#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list