Make WordPress Core


Ignore:
Timestamp:
02/15/2017 05:58:14 PM (8 years ago)
Author:
adamsilverstein
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php

    r39436 r40061  
    1111  */
    1212class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase {
     13    protected static $wp_meta_keys_saved;
    1314    protected static $post_id;
    1415
    1516    public static function wpSetUpBeforeClass( $factory ) {
     17        self::$wp_meta_keys_saved = $GLOBALS['wp_meta_keys'];
    1618        self::$post_id = $factory->post->create();
    1719    }
    1820
    1921    public static function wpTearDownAfterClass() {
     22        $GLOBALS['wp_meta_keys'] = self::$wp_meta_keys_saved;
    2023        wp_delete_post( self::$post_id, true );
    2124    }
Note: See TracChangeset for help on using the changeset viewer.