Make WordPress Core

Ticket #39805: 39805.3.diff

File 39805.3.diff, 3.3 KB (added by kadamwhite, 9 years ago)

Adjust unit tests per patch feedback

  • src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
    index 25e9c9a..583f732 100644
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19411941                                        $schema['properties']['featured_media'] = array(
    19421942                                                'description' => __( 'The ID of the featured media for the object.' ),
    19431943                                                'type'        => 'integer',
    1944                                                 'context'     => array( 'view', 'edit' ),
     1944                                                'context'     => array( 'view', 'edit', 'embed' ),
    19451945                                        );
    19461946                                        break;
    19471947
  • tests/phpunit/tests/rest-api/rest-posts-controller.php

    diff --git tests/phpunit/tests/rest-api/rest-posts-controller.php tests/phpunit/tests/rest-api/rest-posts-controller.php
    index ca16356..718bf65 100644
    class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    26592659                $this->assertArrayHasKey( 'categories', $properties );
    26602660        }
    26612661
     2662        /**
     2663         * @ticket 39805
     2664         */
     2665        public function test_get_post_view_context_properties() {
     2666                $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
     2667                $request->set_param( 'context', 'view' );
     2668                $response = $this->server->dispatch( $request );
     2669                $keys = array_keys( $response->get_data() );
     2670                sort( $keys );
     2671
     2672                $expected_keys = array(
     2673                        'author',
     2674                        'categories',
     2675                        'comment_status',
     2676                        'content',
     2677                        'date',
     2678                        'date_gmt',
     2679                        'excerpt',
     2680                        'featured_media',
     2681                        'format',
     2682                        'guid',
     2683                        'id',
     2684                        'link',
     2685                        'meta',
     2686                        'modified',
     2687                        'modified_gmt',
     2688                        'ping_status',
     2689                        'slug',
     2690                        'sticky',
     2691                        'tags',
     2692                        'template',
     2693                        'title',
     2694                        'type',
     2695                );
     2696
     2697                $this->assertEquals( $expected_keys, $keys );
     2698        }
     2699
     2700        public function test_get_post_edit_context_properties() {
     2701                wp_set_current_user( self::$editor_id );
     2702
     2703                $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
     2704                $request->set_param( 'context', 'edit' );
     2705                $response = $this->server->dispatch( $request );
     2706                $keys = array_keys( $response->get_data() );
     2707                sort( $keys );
     2708
     2709                $expected_keys = array(
     2710                        'author',
     2711                        'categories',
     2712                        'comment_status',
     2713                        'content',
     2714                        'date',
     2715                        'date_gmt',
     2716                        'excerpt',
     2717                        'featured_media',
     2718                        'format',
     2719                        'guid',
     2720                        'id',
     2721                        'link',
     2722                        'meta',
     2723                        'modified',
     2724                        'modified_gmt',
     2725                        'password',
     2726                        'ping_status',
     2727                        'slug',
     2728                        'status',
     2729                        'sticky',
     2730                        'tags',
     2731                        'template',
     2732                        'title',
     2733                        'type',
     2734                );
     2735
     2736                $this->assertEquals( $expected_keys, $keys );
     2737        }
     2738
     2739        public function test_get_post_embed_context_properties() {
     2740                $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
     2741                $request->set_param( 'context', 'embed' );
     2742                $response = $this->server->dispatch( $request );
     2743                $keys = array_keys( $response->get_data() );
     2744                sort( $keys );
     2745
     2746                $expected_keys = array(
     2747                        'author',
     2748                        'date',
     2749                        'excerpt',
     2750                        'featured_media',
     2751                        'id',
     2752                        'link',
     2753                        'slug',
     2754                        'title',
     2755                        'type',
     2756                );
     2757
     2758                $this->assertEquals( $expected_keys, $keys );
     2759        }
     2760
    26622761        public function test_status_array_enum_args() {
    26632762                $request = new WP_REST_Request( 'GET', '/wp/v2' );
    26642763                $response = $this->server->dispatch( $request );