| | 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 | $data = $response->get_data(); |
| | 2670 | |
| | 2671 | foreach( array( |
| | 2672 | 'author', |
| | 2673 | 'categories', |
| | 2674 | 'comment_status', |
| | 2675 | 'content', |
| | 2676 | 'date', |
| | 2677 | 'date_gmt', |
| | 2678 | 'excerpt', |
| | 2679 | 'featured_media', |
| | 2680 | 'format', |
| | 2681 | 'guid', |
| | 2682 | 'id', |
| | 2683 | 'link', |
| | 2684 | 'meta', |
| | 2685 | 'modified', |
| | 2686 | 'modified_gmt', |
| | 2687 | 'ping_status', |
| | 2688 | 'slug', |
| | 2689 | 'sticky', |
| | 2690 | 'tags', |
| | 2691 | 'template', |
| | 2692 | 'title', |
| | 2693 | 'type', |
| | 2694 | ) as $key ) { |
| | 2695 | $this->assertArrayHasKey( $key, $data ); |
| | 2696 | } |
| | 2697 | } |
| | 2698 | |
| | 2699 | public function test_get_post_edit_context_properties() { |
| | 2700 | wp_set_current_user( self::$editor_id ); |
| | 2701 | |
| | 2702 | $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); |
| | 2703 | $request->set_param( 'context', 'edit' ); |
| | 2704 | $response = $this->server->dispatch( $request ); |
| | 2705 | $data = $response->get_data(); |
| | 2706 | |
| | 2707 | foreach( array( |
| | 2708 | 'author', |
| | 2709 | 'categories', |
| | 2710 | 'comment_status', |
| | 2711 | 'content', |
| | 2712 | 'date', |
| | 2713 | 'date_gmt', |
| | 2714 | 'excerpt', |
| | 2715 | 'featured_media', |
| | 2716 | 'format', |
| | 2717 | 'guid', |
| | 2718 | 'id', |
| | 2719 | 'link', |
| | 2720 | 'meta', |
| | 2721 | 'modified', |
| | 2722 | 'modified_gmt', |
| | 2723 | 'password', |
| | 2724 | 'ping_status', |
| | 2725 | 'slug', |
| | 2726 | 'status', |
| | 2727 | 'sticky', |
| | 2728 | 'tags', |
| | 2729 | 'template', |
| | 2730 | 'title', |
| | 2731 | 'type', |
| | 2732 | ) as $key ) { |
| | 2733 | $this->assertArrayHasKey( $key, $data ); |
| | 2734 | } |
| | 2735 | } |
| | 2736 | |
| | 2737 | public function test_get_post_embed_context_properties() { |
| | 2738 | $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); |
| | 2739 | $request->set_param( 'context', 'embed' ); |
| | 2740 | $response = $this->server->dispatch( $request ); |
| | 2741 | $data = $response->get_data(); |
| | 2742 | |
| | 2743 | foreach( array( |
| | 2744 | 'author', |
| | 2745 | 'date', |
| | 2746 | 'excerpt', |
| | 2747 | 'featured_media', |
| | 2748 | 'id', |
| | 2749 | 'link', |
| | 2750 | 'slug', |
| | 2751 | 'title', |
| | 2752 | 'type', |
| | 2753 | ) as $key ) { |
| | 2754 | $this->assertArrayHasKey( $key, $data ); |
| | 2755 | } |
| | 2756 | } |
| | 2757 | |