You appear to be a bot. Output may be restricted
Description
Tests autosaving a locked post.
Usage
Tests_Ajax_Autosave::test_autosave_locked_post();
Parameters
Returns
void
Source
File name: wordpress-develop-tests/phpunit/tests/ajax/Autosave.php
Lines:
1 to 50 of 50
public function test_autosave_locked_post() { // Lock the post to another user. wp_set_current_user( self::$editor_id ); wp_set_post_lock( self::$post_id ); wp_set_current_user( self::$admin_id ); // Ensure post is locked. $this->assertEquals( self::$editor_id, wp_check_post_lock( self::$post_id ) ); // Set up the $_POST request. $md5 = md5( uniqid() ); $_POST = array( 'action' => 'heartbeat', '_nonce' => wp_create_nonce( 'heartbeat-nonce' ), 'data' => array( 'wp_autosave' => array( 'post_id' => self::$post_id, '_wpnonce' => wp_create_nonce( 'update-post_' . self::$post_id ), 'post_content' => self::$post->post_content . PHP_EOL . $md5, 'post_type' => 'post', ), ), ); // Make the request. try { $this->_handleAjax( 'heartbeat' ); } catch ( WPAjaxDieContinueException $e ) { unset( $e ); } $response = json_decode( $this->_last_response, true ); // Ensure everything is correct. $this->assertNotEmpty( $response['wp_autosave'] ); $this->assertTrue( $response['wp_autosave']['success'] ); // Check that the original post was NOT edited. $post = get_post( self::$post_id ); $this->assertStringNotContainsString( $md5, $post->post_content ); // Check if the autosave post was created. $autosave = wp_get_post_autosave( self::$post_id, get_current_user_id() ); $this->assertNotEmpty( $autosave ); $this->assertStringContainsString( $md5, $autosave->post_content ); }