Changeset 42343 for trunk/tests/phpunit/tests/ajax/Autosave.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/ajax/Autosave.php
r38398 r42343 18 18 /** 19 19 * Post 20 * 20 21 * @var mixed 21 22 */ 22 23 protected $_post = null; 23 24 24 protected static $admin_id = 0;25 protected static $admin_id = 0; 25 26 protected static $editor_id = 0; 26 27 protected static $post; … … 33 34 34 35 self::$post_id = $factory->post->create( array( 'post_status' => 'draft' ) ); 35 self::$post = get_post( self::$post_id );36 self::$post = get_post( self::$post_id ); 36 37 } 37 38 … … 47 48 /** 48 49 * Test autosaving a post 50 * 49 51 * @return void 50 52 */ … … 54 56 55 57 // Set up the $_POST request 56 $md5 = md5( uniqid() );58 $md5 = md5( uniqid() ); 57 59 $_POST = array( 58 'action' => 60 'action' => 'heartbeat', 59 61 '_nonce' => wp_create_nonce( 'heartbeat-nonce' ), 60 'data' => array(62 'data' => array( 61 63 'wp_autosave' => array( 62 'post_id'=> self::$post_id,63 '_wpnonce'=> wp_create_nonce( 'update-post_' . self::$post->ID ),64 'post_content'=> self::$post->post_content . PHP_EOL . $md5,65 'post_type' 64 'post_id' => self::$post_id, 65 '_wpnonce' => wp_create_nonce( 'update-post_' . self::$post->ID ), 66 'post_content' => self::$post->post_content . PHP_EOL . $md5, 67 'post_type' => 'post', 66 68 ), 67 69 ), … … 89 91 /** 90 92 * Test autosaving a locked post 93 * 91 94 * @return void 92 95 */ … … 102 105 103 106 // Set up the $_POST request 104 $md5 = md5( uniqid() );107 $md5 = md5( uniqid() ); 105 108 $_POST = array( 106 'action' => 109 'action' => 'heartbeat', 107 110 '_nonce' => wp_create_nonce( 'heartbeat-nonce' ), 108 'data' => array(111 'data' => array( 109 112 'wp_autosave' => array( 110 'post_id'=> self::$post_id,111 '_wpnonce'=> wp_create_nonce( 'update-post_' . self::$post_id ),112 'post_content'=> self::$post->post_content . PHP_EOL . $md5,113 'post_type' 113 'post_id' => self::$post_id, 114 '_wpnonce' => wp_create_nonce( 'update-post_' . self::$post_id ), 115 'post_content' => self::$post->post_content . PHP_EOL . $md5, 116 'post_type' => 'post', 114 117 ), 115 118 ), … … 141 144 /** 142 145 * Test with an invalid nonce 146 * 143 147 * @return void 144 148 */ 145 public function test_with_invalid_nonce( 149 public function test_with_invalid_nonce() { 146 150 147 151 wp_set_current_user( self::$admin_id ); … … 149 153 // Set up the $_POST request 150 154 $_POST = array( 151 'action' => 155 'action' => 'heartbeat', 152 156 '_nonce' => wp_create_nonce( 'heartbeat-nonce' ), 153 'data' => array(157 'data' => array( 154 158 'wp_autosave' => array( 155 156 159 'post_id' => self::$post_id, 160 '_wpnonce' => substr( md5( uniqid() ), 0, 10 ), 157 161 ), 158 162 ),
Note: See TracChangeset
for help on using the changeset viewer.