| | 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 | |