Changeset 42343 for trunk/tests/phpunit/tests/post/slashes.php
- Timestamp:
- 11/30/2017 11:09:33 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/slashes.php
r35244 r42343 26 26 /** 27 27 * Tests the controller function that expects slashed data 28 *29 28 */ 30 29 function test_edit_post() { 31 30 $id = self::factory()->post->create(); 32 31 33 $_POST = array();34 $_POST['post_ID'] = $id;32 $_POST = array(); 33 $_POST['post_ID'] = $id; 35 34 $_POST['post_title'] = $this->slash_1; 36 $_POST['content'] = $this->slash_5;37 $_POST['excerpt'] = $this->slash_7;38 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes35 $_POST['content'] = $this->slash_5; 36 $_POST['excerpt'] = $this->slash_7; 37 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes 39 38 40 39 $post_id = edit_post(); 41 $post = get_post( $post_id );40 $post = get_post( $post_id ); 42 41 43 42 $this->assertEquals( $this->slash_1, $post->post_title ); … … 45 44 $this->assertEquals( $this->slash_7, $post->post_excerpt ); 46 45 47 $_POST = array();48 $_POST['post_ID'] = $id;46 $_POST = array(); 47 $_POST['post_ID'] = $id; 49 48 $_POST['post_title'] = $this->slash_2; 50 $_POST['content'] = $this->slash_4;51 $_POST['excerpt'] = $this->slash_6;52 $_POST = add_magic_quotes( $_POST );49 $_POST['content'] = $this->slash_4; 50 $_POST['excerpt'] = $this->slash_6; 51 $_POST = add_magic_quotes( $_POST ); 53 52 54 53 $post_id = edit_post(); 55 $post = get_post( $post_id );54 $post = get_post( $post_id ); 56 55 57 56 $this->assertEquals( $this->slash_2, $post->post_title ); … … 62 61 /** 63 62 * Tests the model function that expects slashed data 64 *65 63 */ 66 64 function test_wp_insert_post() { 67 $id = wp_insert_post(array( 68 'post_status' => 'publish', 69 'post_title' => $this->slash_1, 70 'post_content' => $this->slash_3, 71 'post_excerpt' => $this->slash_5, 72 'post_type' => 'post', 73 'slashed' => false, 74 )); 65 $id = wp_insert_post( 66 array( 67 'post_status' => 'publish', 68 'post_title' => $this->slash_1, 69 'post_content' => $this->slash_3, 70 'post_excerpt' => $this->slash_5, 71 'post_type' => 'post', 72 'slashed' => false, 73 ) 74 ); 75 75 $post = get_post( $id ); 76 76 … … 79 79 $this->assertEquals( wp_unslash( $this->slash_5 ), $post->post_excerpt ); 80 80 81 $id = wp_insert_post(array( 82 'post_status' => 'publish', 83 'post_title' => $this->slash_2, 84 'post_content' => $this->slash_4, 85 'post_excerpt' => $this->slash_6, 86 'post_type' => 'post' 87 )); 81 $id = wp_insert_post( 82 array( 83 'post_status' => 'publish', 84 'post_title' => $this->slash_2, 85 'post_content' => $this->slash_4, 86 'post_excerpt' => $this->slash_6, 87 'post_type' => 'post', 88 ) 89 ); 88 90 $post = get_post( $id ); 89 91 … … 95 97 /** 96 98 * Tests the model function that expects slashed data 97 *98 99 */ 99 100 function test_wp_update_post() { 100 101 $id = self::factory()->post->create(); 101 102 102 wp_update_post(array( 103 'ID' => $id, 104 'post_title' => $this->slash_1, 105 'post_content' => $this->slash_3, 106 'post_excerpt' => $this->slash_5, 107 )); 103 wp_update_post( 104 array( 105 'ID' => $id, 106 'post_title' => $this->slash_1, 107 'post_content' => $this->slash_3, 108 'post_excerpt' => $this->slash_5, 109 ) 110 ); 108 111 $post = get_post( $id ); 109 112 … … 112 115 $this->assertEquals( wp_unslash( $this->slash_5 ), $post->post_excerpt ); 113 116 114 wp_update_post(array( 115 'ID' => $id, 116 'post_title' => $this->slash_2, 117 'post_content' => $this->slash_4, 118 'post_excerpt' => $this->slash_6, 119 )); 117 wp_update_post( 118 array( 119 'ID' => $id, 120 'post_title' => $this->slash_2, 121 'post_content' => $this->slash_4, 122 'post_excerpt' => $this->slash_6, 123 ) 124 ); 120 125 $post = get_post( $id ); 121 126 … … 134 139 'post_excerpt' => $this->slash_5, 135 140 ); 136 $id = wp_insert_post( wp_slash( $post ) );141 $id = wp_insert_post( wp_slash( $post ) ); 137 142 138 143 $trashed = wp_trash_post( $id );
Note: See TracChangeset
for help on using the changeset viewer.