Changeset 42343 for trunk/tests/phpunit/tests/comment/slashes.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment/slashes.php
r35244 r42343 26 26 /** 27 27 * Tests the extended model function that expects slashed data 28 *29 28 */ 30 29 function test_wp_new_comment() { … … 34 33 // as slashes are not permitted in that data 35 34 $data = array( 36 'comment_post_ID' => $post_id,37 'comment_author' => $this->slash_1,38 'comment_author_url' => '',35 'comment_post_ID' => $post_id, 36 'comment_author' => $this->slash_1, 37 'comment_author_url' => '', 39 38 'comment_author_email' => '', 40 'comment_type' => '',41 'comment_content' => $this->slash_7,39 'comment_type' => '', 40 'comment_content' => $this->slash_7, 42 41 ); 43 $id = wp_new_comment( $data );42 $id = wp_new_comment( $data ); 44 43 45 $comment = get_comment( $id);44 $comment = get_comment( $id ); 46 45 47 46 $this->assertEquals( wp_unslash( $this->slash_1 ), $comment->comment_author ); … … 49 48 50 49 $data = array( 51 'comment_post_ID' => $post_id,52 'comment_author' => $this->slash_2,53 'comment_author_url' => '',50 'comment_post_ID' => $post_id, 51 'comment_author' => $this->slash_2, 52 'comment_author_url' => '', 54 53 'comment_author_email' => '', 55 'comment_type' => '',56 'comment_content' => $this->slash_4,54 'comment_type' => '', 55 'comment_content' => $this->slash_4, 57 56 ); 58 $id = wp_new_comment( $data );57 $id = wp_new_comment( $data ); 59 58 60 $comment = get_comment( $id);59 $comment = get_comment( $id ); 61 60 62 61 $this->assertEquals( wp_unslash( $this->slash_2 ), $comment->comment_author ); … … 66 65 /** 67 66 * Tests the controller function that expects slashed data 68 *69 67 */ 70 68 function test_edit_comment() { 71 $post_id = self::factory()->post->create(); 72 $comment_id = self::factory()->comment->create(array( 73 'comment_post_ID' => $post_id 74 )); 69 $post_id = self::factory()->post->create(); 70 $comment_id = self::factory()->comment->create( 71 array( 72 'comment_post_ID' => $post_id, 73 ) 74 ); 75 75 76 76 // not testing comment_author_email or comment_author_url 77 77 // as slashes are not permitted in that data 78 $_POST = array();79 $_POST['comment_ID'] = $comment_id;80 $_POST['comment_status'] = '';81 $_POST['newcomment_author'] = $this->slash_1;82 $_POST['newcomment_author_url'] = '';78 $_POST = array(); 79 $_POST['comment_ID'] = $comment_id; 80 $_POST['comment_status'] = ''; 81 $_POST['newcomment_author'] = $this->slash_1; 82 $_POST['newcomment_author_url'] = ''; 83 83 $_POST['newcomment_author_email'] = ''; 84 $_POST['content'] = $this->slash_7;85 $_POST = add_magic_quotes( $_POST );84 $_POST['content'] = $this->slash_7; 85 $_POST = add_magic_quotes( $_POST ); 86 86 87 87 edit_comment(); … … 91 91 $this->assertEquals( $this->slash_7, $comment->comment_content ); 92 92 93 $_POST = array();94 $_POST['comment_ID'] = $comment_id;95 $_POST['comment_status'] = '';96 $_POST['newcomment_author'] = $this->slash_2;97 $_POST['newcomment_author_url'] = '';93 $_POST = array(); 94 $_POST['comment_ID'] = $comment_id; 95 $_POST['comment_status'] = ''; 96 $_POST['newcomment_author'] = $this->slash_2; 97 $_POST['newcomment_author_url'] = ''; 98 98 $_POST['newcomment_author_email'] = ''; 99 $_POST['content'] = $this->slash_4;100 $_POST = add_magic_quotes( $_POST );99 $_POST['content'] = $this->slash_4; 100 $_POST = add_magic_quotes( $_POST ); 101 101 102 102 edit_comment(); … … 109 109 /** 110 110 * Tests the model function that expects slashed data 111 *112 111 */ 113 112 function test_wp_insert_comment() { 114 113 $post_id = self::factory()->post->create(); 115 114 116 $comment_id = wp_insert_comment(array( 117 'comment_post_ID' => $post_id, 118 'comment_author' => $this->slash_1, 119 'comment_content' => $this->slash_7, 120 )); 121 $comment = get_comment( $comment_id ); 115 $comment_id = wp_insert_comment( 116 array( 117 'comment_post_ID' => $post_id, 118 'comment_author' => $this->slash_1, 119 'comment_content' => $this->slash_7, 120 ) 121 ); 122 $comment = get_comment( $comment_id ); 122 123 123 124 $this->assertEquals( wp_unslash( $this->slash_1 ), $comment->comment_author ); 124 125 $this->assertEquals( wp_unslash( $this->slash_7 ), $comment->comment_content ); 125 126 126 $comment_id = wp_insert_comment(array( 127 'comment_post_ID' => $post_id, 128 'comment_author' => $this->slash_2, 129 'comment_content' => $this->slash_4, 130 )); 131 $comment = get_comment( $comment_id ); 127 $comment_id = wp_insert_comment( 128 array( 129 'comment_post_ID' => $post_id, 130 'comment_author' => $this->slash_2, 131 'comment_content' => $this->slash_4, 132 ) 133 ); 134 $comment = get_comment( $comment_id ); 132 135 133 136 $this->assertEquals( wp_unslash( $this->slash_2 ), $comment->comment_author ); … … 137 140 /** 138 141 * Tests the model function that expects slashed data 139 *140 142 */ 141 143 function test_wp_update_comment() { 142 $post_id = self::factory()->post->create(); 143 $comment_id = self::factory()->comment->create(array( 144 'comment_post_ID' => $post_id 145 )); 144 $post_id = self::factory()->post->create(); 145 $comment_id = self::factory()->comment->create( 146 array( 147 'comment_post_ID' => $post_id, 148 ) 149 ); 146 150 147 wp_update_comment(array( 148 'comment_ID' => $comment_id, 149 'comment_author' => $this->slash_1, 150 'comment_content' => $this->slash_7, 151 )); 151 wp_update_comment( 152 array( 153 'comment_ID' => $comment_id, 154 'comment_author' => $this->slash_1, 155 'comment_content' => $this->slash_7, 156 ) 157 ); 152 158 $comment = get_comment( $comment_id ); 153 159 … … 155 161 $this->assertEquals( wp_unslash( $this->slash_7 ), $comment->comment_content ); 156 162 157 wp_update_comment(array( 158 'comment_ID' => $comment_id, 159 'comment_author' => $this->slash_2, 160 'comment_content' => $this->slash_4, 161 )); 163 wp_update_comment( 164 array( 165 'comment_ID' => $comment_id, 166 'comment_author' => $this->slash_2, 167 'comment_content' => $this->slash_4, 168 ) 169 ); 162 170 $comment = get_comment( $comment_id ); 163 171
Note: See TracChangeset
for help on using the changeset viewer.