Index: branches/5.0/tests/phpunit/tests/rest-api/rest-posts-controller.php =================================================================== --- branches/5.0/tests/phpunit/tests/rest-api/rest-posts-controller.php (revision 43732) +++ branches/5.0/tests/phpunit/tests/rest-api/rest-posts-controller.php (revision 43770) @@ -1331,4 +1331,63 @@ $this->assertEquals( '', $data['excerpt']['rendered'] ); $this->assertTrue( $data['excerpt']['protected'] ); + } + + /** + * The post response should not have `block_version` when in view context. + * + * @ticket 43887 + */ + public function test_get_post_should_not_have_block_version_when_context_view() { + $post_id = $this->factory->post->create( + array( + 'post_content' => '', + ) + ); + + $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $post_id ) ); + $response = rest_get_server()->dispatch( $request ); + $data = $response->get_data(); + $this->assertFalse( isset( $data['content']['block_version'] ) ); + } + + /** + * The post response should have `block_version` indicate that block content is present when in edit context. + * + * @ticket 43887 + */ + public function test_get_post_should_have_block_version_indicate_block_content_when_context_edit() { + wp_set_current_user( self::$editor_id ); + + $post_id = $this->factory->post->create( + array( + 'post_content' => '', + ) + ); + + $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $post_id ) ); + $request->set_param( 'context', 'edit' ); + $response = rest_get_server()->dispatch( $request ); + $data = $response->get_data(); + $this->assertSame( 1, $data['content']['block_version'] ); + } + + /** + * The post response should have `block_version` indicate that no block content is present when in edit context. + * + * @ticket 43887 + */ + public function test_get_post_should_have_block_version_indicate_no_block_content_when_context_edit() { + wp_set_current_user( self::$editor_id ); + + $post_id = $this->factory->post->create( + array( + 'post_content' => '