Changeset 42343 for trunk/tests/phpunit/tests/user/slashes.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/user/slashes.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/slashes.php
r35244 r42343 26 26 /** 27 27 * Tests the controller function that expects slashed data 28 *29 28 */ 30 29 function test_add_user() { 31 $_POST = $_GET = $_REQUEST = array();32 $_POST['user_login'] = 'slash_example_user_1';33 $_POST['pass1'] = 'password';34 $_POST['pass2'] = 'password';35 $_POST['role'] = 'subscriber';36 $_POST['email'] = 'user1@example.com';37 $_POST['first_name'] = $this->slash_1;38 $_POST['last_name'] = $this->slash_3;39 $_POST['nickname'] = $this->slash_5;30 $_POST = $_GET = $_REQUEST = array(); 31 $_POST['user_login'] = 'slash_example_user_1'; 32 $_POST['pass1'] = 'password'; 33 $_POST['pass2'] = 'password'; 34 $_POST['role'] = 'subscriber'; 35 $_POST['email'] = 'user1@example.com'; 36 $_POST['first_name'] = $this->slash_1; 37 $_POST['last_name'] = $this->slash_3; 38 $_POST['nickname'] = $this->slash_5; 40 39 $_POST['display_name'] = $this->slash_7; 41 $_POST['description'] = $this->slash_3;42 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes43 44 $id = add_user();40 $_POST['description'] = $this->slash_3; 41 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes 42 43 $id = add_user(); 45 44 $user = get_user_to_edit( $id ); 46 45 … … 51 50 $this->assertEquals( $this->slash_3, $user->description ); 52 51 53 $_POST = $_GET = $_REQUEST = array();54 $_POST['user_login'] = 'slash_example_user_2';55 $_POST['pass1'] = 'password';56 $_POST['pass2'] = 'password';57 $_POST['role'] = 'subscriber';58 $_POST['email'] = 'user2@example.com';59 $_POST['first_name'] = $this->slash_2;60 $_POST['last_name'] = $this->slash_4;61 $_POST['nickname'] = $this->slash_6;52 $_POST = $_GET = $_REQUEST = array(); 53 $_POST['user_login'] = 'slash_example_user_2'; 54 $_POST['pass1'] = 'password'; 55 $_POST['pass2'] = 'password'; 56 $_POST['role'] = 'subscriber'; 57 $_POST['email'] = 'user2@example.com'; 58 $_POST['first_name'] = $this->slash_2; 59 $_POST['last_name'] = $this->slash_4; 60 $_POST['nickname'] = $this->slash_6; 62 61 $_POST['display_name'] = $this->slash_2; 63 $_POST['description'] = $this->slash_4;64 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes65 66 $id = add_user();62 $_POST['description'] = $this->slash_4; 63 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes 64 65 $id = add_user(); 67 66 $user = get_user_to_edit( $id ); 68 67 … … 76 75 /** 77 76 * Tests the controller function that expects slashed data 78 *79 77 */ 80 78 function test_edit_user() { 81 79 $id = self::factory()->user->create(); 82 80 83 $_POST = $_GET = $_REQUEST = array();84 $_POST['role'] = 'subscriber';85 $_POST['email'] = 'user1@example.com';86 $_POST['first_name'] = $this->slash_1;87 $_POST['last_name'] = $this->slash_3;88 $_POST['nickname'] = $this->slash_5;81 $_POST = $_GET = $_REQUEST = array(); 82 $_POST['role'] = 'subscriber'; 83 $_POST['email'] = 'user1@example.com'; 84 $_POST['first_name'] = $this->slash_1; 85 $_POST['last_name'] = $this->slash_3; 86 $_POST['nickname'] = $this->slash_5; 89 87 $_POST['display_name'] = $this->slash_7; 90 $_POST['description'] = $this->slash_3;91 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes92 93 $id = edit_user( $id );88 $_POST['description'] = $this->slash_3; 89 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes 90 91 $id = edit_user( $id ); 94 92 $user = get_user_to_edit( $id ); 95 93 … … 100 98 $this->assertEquals( $this->slash_3, $user->description ); 101 99 102 $_POST = $_GET = $_REQUEST = array();103 $_POST['role'] = 'subscriber';104 $_POST['email'] = 'user2@example.com';105 $_POST['first_name'] = $this->slash_2;106 $_POST['last_name'] = $this->slash_4;107 $_POST['nickname'] = $this->slash_6;100 $_POST = $_GET = $_REQUEST = array(); 101 $_POST['role'] = 'subscriber'; 102 $_POST['email'] = 'user2@example.com'; 103 $_POST['first_name'] = $this->slash_2; 104 $_POST['last_name'] = $this->slash_4; 105 $_POST['nickname'] = $this->slash_6; 108 106 $_POST['display_name'] = $this->slash_2; 109 $_POST['description'] = $this->slash_4;110 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes111 112 $id = edit_user( $id );107 $_POST['description'] = $this->slash_4; 108 $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes 109 110 $id = edit_user( $id ); 113 111 $user = get_user_to_edit( $id ); 114 112 … … 122 120 /** 123 121 * Tests the model function that expects slashed data 124 *125 122 */ 126 123 function test_wp_insert_user() { 127 $id = wp_insert_user( array( 128 'user_login' => 'slash_example_user_3', 129 'role' => 'subscriber', 130 'email' => 'user3@example.com', 131 'first_name' => $this->slash_1, 132 'last_name' => $this->slash_3, 133 'nickname' => $this->slash_5, 134 'display_name' => $this->slash_7, 135 'description' => $this->slash_3, 136 'user_pass' => '' 137 ) ); 124 $id = wp_insert_user( 125 array( 126 'user_login' => 'slash_example_user_3', 127 'role' => 'subscriber', 128 'email' => 'user3@example.com', 129 'first_name' => $this->slash_1, 130 'last_name' => $this->slash_3, 131 'nickname' => $this->slash_5, 132 'display_name' => $this->slash_7, 133 'description' => $this->slash_3, 134 'user_pass' => '', 135 ) 136 ); 138 137 $user = get_user_to_edit( $id ); 139 138 … … 144 143 $this->assertEquals( wp_unslash( $this->slash_3 ), $user->description ); 145 144 146 $id = wp_insert_user( array( 147 'user_login' => 'slash_example_user_4', 148 'role' => 'subscriber', 149 'email' => 'user3@example.com', 150 'first_name' => $this->slash_2, 151 'last_name' => $this->slash_4, 152 'nickname' => $this->slash_6, 153 'display_name' => $this->slash_2, 154 'description' => $this->slash_4, 155 'user_pass' => '' 156 ) ); 145 $id = wp_insert_user( 146 array( 147 'user_login' => 'slash_example_user_4', 148 'role' => 'subscriber', 149 'email' => 'user3@example.com', 150 'first_name' => $this->slash_2, 151 'last_name' => $this->slash_4, 152 'nickname' => $this->slash_6, 153 'display_name' => $this->slash_2, 154 'description' => $this->slash_4, 155 'user_pass' => '', 156 ) 157 ); 157 158 $user = get_user_to_edit( $id ); 158 159 … … 166 167 /** 167 168 * Tests the model function that expects slashed data 168 *169 169 */ 170 170 function test_wp_update_user() { 171 $id = self::factory()->user->create(); 172 $id = wp_update_user(array( 173 'ID' => $id, 174 'role' => 'subscriber', 175 'first_name' => $this->slash_1, 176 'last_name' => $this->slash_3, 177 'nickname' => $this->slash_5, 178 'display_name' => $this->slash_7, 179 'description' => $this->slash_3, 180 )); 171 $id = self::factory()->user->create(); 172 $id = wp_update_user( 173 array( 174 'ID' => $id, 175 'role' => 'subscriber', 176 'first_name' => $this->slash_1, 177 'last_name' => $this->slash_3, 178 'nickname' => $this->slash_5, 179 'display_name' => $this->slash_7, 180 'description' => $this->slash_3, 181 ) 182 ); 181 183 $user = get_user_to_edit( $id ); 182 184 … … 187 189 $this->assertEquals( wp_unslash( $this->slash_3 ), $user->description ); 188 190 189 $id = wp_update_user(array( 190 'ID' => $id, 191 'role' => 'subscriber', 192 'first_name' => $this->slash_2, 193 'last_name' => $this->slash_4, 194 'nickname' => $this->slash_6, 195 'display_name' => $this->slash_2, 196 'description' => $this->slash_4, 197 )); 191 $id = wp_update_user( 192 array( 193 'ID' => $id, 194 'role' => 'subscriber', 195 'first_name' => $this->slash_2, 196 'last_name' => $this->slash_4, 197 'nickname' => $this->slash_6, 198 'display_name' => $this->slash_2, 199 'description' => $this->slash_4, 200 ) 201 ); 198 202 $user = get_user_to_edit( $id ); 199 203
Note: See TracChangeset
for help on using the changeset viewer.