diff --git a/tests/phpunit/tests/attachment/slashes.php b/tests/phpunit/tests/attachment/slashes.php index 14bf7d401784..8bd8a8290abd 100644 --- a/tests/phpunit/tests/attachment/slashes.php +++ b/tests/phpunit/tests/attachment/slashes.php @@ -32,7 +32,7 @@ function setUp() { * Tests the model function that expects slashed data. */ function test_wp_insert_attachment() { - $id = wp_insert_attachment( + $post_id = wp_insert_attachment( array( 'post_status' => 'publish', 'post_title' => $this->slash_1, @@ -41,13 +41,13 @@ function test_wp_insert_attachment() { 'post_type' => 'post', ) ); - $post = get_post( $id ); + $post = get_post( $post_id ); $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title ); $this->assertSame( wp_unslash( $this->slash_3 ), $post->post_content_filtered ); $this->assertSame( wp_unslash( $this->slash_5 ), $post->post_excerpt ); - $id = wp_insert_attachment( + $post_id = wp_insert_attachment( array( 'post_status' => 'publish', 'post_title' => $this->slash_2, @@ -56,7 +56,7 @@ function test_wp_insert_attachment() { 'post_type' => 'post', ) ); - $post = get_post( $id ); + $post = get_post( $post_id ); $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title ); $this->assertSame( wp_unslash( $this->slash_4 ), $post->post_content_filtered ); diff --git a/tests/phpunit/tests/comment/slashes.php b/tests/phpunit/tests/comment/slashes.php index d6370c342e41..beb998e11c0a 100644 --- a/tests/phpunit/tests/comment/slashes.php +++ b/tests/phpunit/tests/comment/slashes.php @@ -37,7 +37,7 @@ function test_wp_new_comment() { // Not testing comment_author_email or comment_author_url // as slashes are not permitted in that data. - $data = array( + $data = array( 'comment_post_ID' => $post_id, 'comment_author' => $this->slash_1, 'comment_author_url' => '', @@ -45,14 +45,14 @@ function test_wp_new_comment() { 'comment_type' => '', 'comment_content' => $this->slash_7, ); - $id = wp_new_comment( $data ); + $comment_id = wp_new_comment( $data ); - $comment = get_comment( $id ); + $comment = get_comment( $comment_id ); $this->assertSame( wp_unslash( $this->slash_1 ), $comment->comment_author ); $this->assertSame( wp_unslash( $this->slash_7 ), $comment->comment_content ); - $data = array( + $data = array( 'comment_post_ID' => $post_id, 'comment_author' => $this->slash_2, 'comment_author_url' => '', @@ -60,9 +60,9 @@ function test_wp_new_comment() { 'comment_type' => '', 'comment_content' => $this->slash_4, ); - $id = wp_new_comment( $data ); + $comment_id = wp_new_comment( $data ); - $comment = get_comment( $id ); + $comment = get_comment( $comment_id ); $this->assertSame( wp_unslash( $this->slash_2 ), $comment->comment_author ); $this->assertSame( wp_unslash( $this->slash_4 ), $comment->comment_content ); diff --git a/tests/phpunit/tests/meta/slashes.php b/tests/phpunit/tests/meta/slashes.php index 469b04765e91..125cbaaae4df 100644 --- a/tests/phpunit/tests/meta/slashes.php +++ b/tests/phpunit/tests/meta/slashes.php @@ -34,20 +34,21 @@ function setUp() { * Tests the controller function that expects slashed data. */ function test_edit_post() { - $id = self::factory()->post->create(); + $post_id = self::factory()->post->create(); + if ( function_exists( 'wp_add_post_meta' ) ) { - $meta_1 = wp_add_post_meta( $id, 'slash_test_1', 'foo' ); - $meta_2 = wp_add_post_meta( $id, 'slash_test_2', 'foo' ); - $meta_3 = wp_add_post_meta( $id, 'slash_test_3', 'foo' ); + $meta_1 = wp_add_post_meta( $post_id, 'slash_test_1', 'foo' ); + $meta_2 = wp_add_post_meta( $post_id, 'slash_test_2', 'foo' ); + $meta_3 = wp_add_post_meta( $post_id, 'slash_test_3', 'foo' ); } else { // Expects slashed data. - $meta_1 = add_post_meta( $id, 'slash_test_1', addslashes( 'foo' ) ); - $meta_2 = add_post_meta( $id, 'slash_test_2', addslashes( 'foo' ) ); - $meta_3 = add_post_meta( $id, 'slash_test_3', addslashes( 'foo' ) ); + $meta_1 = add_post_meta( $post_id, 'slash_test_1', addslashes( 'foo' ) ); + $meta_2 = add_post_meta( $post_id, 'slash_test_2', addslashes( 'foo' ) ); + $meta_3 = add_post_meta( $post_id, 'slash_test_3', addslashes( 'foo' ) ); } $_POST = array(); - $_POST['post_ID'] = $id; + $_POST['post_ID'] = $post_id; $_POST['metakeyselect'] = '#NONE#'; $_POST['metakeyinput'] = 'slash_test_0'; $_POST['metavalue'] = $this->slash_6; @@ -69,15 +70,15 @@ function test_edit_post() { $_POST = add_magic_quotes( $_POST ); // The edit_post() function will strip slashes. edit_post(); - $post = get_post( $id ); + $post = get_post( $post_id ); - $this->assertSame( $this->slash_6, get_post_meta( $id, 'slash_test_0', true ) ); - $this->assertSame( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) ); - $this->assertSame( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) ); - $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( $this->slash_6, get_post_meta( $post_id, 'slash_test_0', true ) ); + $this->assertSame( $this->slash_1, get_post_meta( $post_id, 'slash_test_1', true ) ); + $this->assertSame( $this->slash_3, get_post_meta( $post_id, 'slash_test_2', true ) ); + $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_3', true ) ); $_POST = array(); - $_POST['post_ID'] = $id; + $_POST['post_ID'] = $post_id; $_POST['metakeyselect'] = '#NONE#'; $_POST['metakeyinput'] = 'slash_test_0'; $_POST['metavalue'] = $this->slash_7; @@ -99,138 +100,140 @@ function test_edit_post() { $_POST = add_magic_quotes( $_POST ); // The edit_post() function will strip slashes. edit_post(); - $post = get_post( $id ); + $post = get_post( $post_id ); - $this->assertSame( $this->slash_2, get_post_meta( $id, 'slash_test_1', true ) ); - $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_2', true ) ); - $this->assertSame( $this->slash_5, get_post_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( $this->slash_2, get_post_meta( $post_id, 'slash_test_1', true ) ); + $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_2', true ) ); + $this->assertSame( $this->slash_5, get_post_meta( $post_id, 'slash_test_3', true ) ); } /** * Tests the legacy model function that expects slashed data. */ function test_add_post_meta() { - $id = self::factory()->post->create(); - add_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) ); - add_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) ); - add_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) ); - - $this->assertSame( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) ); - $this->assertSame( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) ); - $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) ); + $post_id = self::factory()->post->create(); + + add_post_meta( $post_id, 'slash_test_1', addslashes( $this->slash_1 ) ); + add_post_meta( $post_id, 'slash_test_2', addslashes( $this->slash_3 ) ); + add_post_meta( $post_id, 'slash_test_3', addslashes( $this->slash_4 ) ); + + $this->assertSame( $this->slash_1, get_post_meta( $post_id, 'slash_test_1', true ) ); + $this->assertSame( $this->slash_3, get_post_meta( $post_id, 'slash_test_2', true ) ); + $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_3', true ) ); } /** * Tests the legacy model function that expects slashed data. */ function test_update_post_meta() { - $id = self::factory()->post->create(); - update_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) ); - update_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) ); - update_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) ); - - $this->assertSame( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) ); - $this->assertSame( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) ); - $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) ); + $post_id = self::factory()->post->create(); + + update_post_meta( $post_id, 'slash_test_1', addslashes( $this->slash_1 ) ); + update_post_meta( $post_id, 'slash_test_2', addslashes( $this->slash_3 ) ); + update_post_meta( $post_id, 'slash_test_3', addslashes( $this->slash_4 ) ); + + $this->assertSame( $this->slash_1, get_post_meta( $post_id, 'slash_test_1', true ) ); + $this->assertSame( $this->slash_3, get_post_meta( $post_id, 'slash_test_2', true ) ); + $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_3', true ) ); } /** * Tests the model function that expects slashed data. */ function test_add_comment_meta() { - $id = self::$comment_id; + $comment_id = self::$comment_id; - add_comment_meta( $id, 'slash_test_1', $this->slash_1 ); - add_comment_meta( $id, 'slash_test_2', $this->slash_3 ); - add_comment_meta( $id, 'slash_test_3', $this->slash_5 ); + add_comment_meta( $comment_id, 'slash_test_1', $this->slash_1 ); + add_comment_meta( $comment_id, 'slash_test_2', $this->slash_3 ); + add_comment_meta( $comment_id, 'slash_test_3', $this->slash_5 ); - $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $id, 'slash_test_1', true ) ); - $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $id, 'slash_test_2', true ) ); - $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $comment_id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $comment_id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $comment_id, 'slash_test_3', true ) ); - add_comment_meta( $id, 'slash_test_4', $this->slash_2 ); - add_comment_meta( $id, 'slash_test_5', $this->slash_4 ); - add_comment_meta( $id, 'slash_test_6', $this->slash_6 ); + add_comment_meta( $comment_id, 'slash_test_4', $this->slash_2 ); + add_comment_meta( $comment_id, 'slash_test_5', $this->slash_4 ); + add_comment_meta( $comment_id, 'slash_test_6', $this->slash_6 ); - $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $id, 'slash_test_4', true ) ); - $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $id, 'slash_test_5', true ) ); - $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $id, 'slash_test_6', true ) ); + $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $comment_id, 'slash_test_4', true ) ); + $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $comment_id, 'slash_test_5', true ) ); + $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $comment_id, 'slash_test_6', true ) ); } /** * Tests the model function that expects slashed data. */ function test_update_comment_meta() { - $id = self::$comment_id; + $comment_id = self::$comment_id; - add_comment_meta( $id, 'slash_test_1', 'foo' ); - add_comment_meta( $id, 'slash_test_2', 'foo' ); - add_comment_meta( $id, 'slash_test_3', 'foo' ); + add_comment_meta( $comment_id, 'slash_test_1', 'foo' ); + add_comment_meta( $comment_id, 'slash_test_2', 'foo' ); + add_comment_meta( $comment_id, 'slash_test_3', 'foo' ); - update_comment_meta( $id, 'slash_test_1', $this->slash_1 ); - update_comment_meta( $id, 'slash_test_2', $this->slash_3 ); - update_comment_meta( $id, 'slash_test_3', $this->slash_5 ); + update_comment_meta( $comment_id, 'slash_test_1', $this->slash_1 ); + update_comment_meta( $comment_id, 'slash_test_2', $this->slash_3 ); + update_comment_meta( $comment_id, 'slash_test_3', $this->slash_5 ); - $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $id, 'slash_test_1', true ) ); - $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $id, 'slash_test_2', true ) ); - $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $comment_id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $comment_id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $comment_id, 'slash_test_3', true ) ); - update_comment_meta( $id, 'slash_test_1', $this->slash_2 ); - update_comment_meta( $id, 'slash_test_2', $this->slash_4 ); - update_comment_meta( $id, 'slash_test_3', $this->slash_6 ); + update_comment_meta( $comment_id, 'slash_test_1', $this->slash_2 ); + update_comment_meta( $comment_id, 'slash_test_2', $this->slash_4 ); + update_comment_meta( $comment_id, 'slash_test_3', $this->slash_6 ); - $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $id, 'slash_test_1', true ) ); - $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $id, 'slash_test_2', true ) ); - $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $comment_id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $comment_id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $comment_id, 'slash_test_3', true ) ); } /** * Tests the model function that expects slashed data. */ function test_add_user_meta() { - $id = self::factory()->user->create(); + $user_id = self::factory()->user->create(); - add_user_meta( $id, 'slash_test_1', $this->slash_1 ); - add_user_meta( $id, 'slash_test_2', $this->slash_3 ); - add_user_meta( $id, 'slash_test_3', $this->slash_5 ); + add_user_meta( $user_id, 'slash_test_1', $this->slash_1 ); + add_user_meta( $user_id, 'slash_test_2', $this->slash_3 ); + add_user_meta( $user_id, 'slash_test_3', $this->slash_5 ); - $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $id, 'slash_test_1', true ) ); - $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $id, 'slash_test_2', true ) ); - $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $user_id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $user_id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $user_id, 'slash_test_3', true ) ); - add_user_meta( $id, 'slash_test_4', $this->slash_2 ); - add_user_meta( $id, 'slash_test_5', $this->slash_4 ); - add_user_meta( $id, 'slash_test_6', $this->slash_6 ); + add_user_meta( $user_id, 'slash_test_4', $this->slash_2 ); + add_user_meta( $user_id, 'slash_test_5', $this->slash_4 ); + add_user_meta( $user_id, 'slash_test_6', $this->slash_6 ); - $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $id, 'slash_test_4', true ) ); - $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $id, 'slash_test_5', true ) ); - $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $id, 'slash_test_6', true ) ); + $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $user_id, 'slash_test_4', true ) ); + $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $user_id, 'slash_test_5', true ) ); + $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $user_id, 'slash_test_6', true ) ); } /** * Tests the model function that expects slashed data. */ function test_update_user_meta() { - $id = self::factory()->user->create(); + $user_id = self::factory()->user->create(); - add_user_meta( $id, 'slash_test_1', 'foo' ); - add_user_meta( $id, 'slash_test_2', 'foo' ); - add_user_meta( $id, 'slash_test_3', 'foo' ); + add_user_meta( $user_id, 'slash_test_1', 'foo' ); + add_user_meta( $user_id, 'slash_test_2', 'foo' ); + add_user_meta( $user_id, 'slash_test_3', 'foo' ); - update_user_meta( $id, 'slash_test_1', $this->slash_1 ); - update_user_meta( $id, 'slash_test_2', $this->slash_3 ); - update_user_meta( $id, 'slash_test_3', $this->slash_5 ); + update_user_meta( $user_id, 'slash_test_1', $this->slash_1 ); + update_user_meta( $user_id, 'slash_test_2', $this->slash_3 ); + update_user_meta( $user_id, 'slash_test_3', $this->slash_5 ); - $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $id, 'slash_test_1', true ) ); - $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $id, 'slash_test_2', true ) ); - $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $user_id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $user_id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $user_id, 'slash_test_3', true ) ); - update_user_meta( $id, 'slash_test_1', $this->slash_2 ); - update_user_meta( $id, 'slash_test_2', $this->slash_4 ); - update_user_meta( $id, 'slash_test_3', $this->slash_6 ); + update_user_meta( $user_id, 'slash_test_1', $this->slash_2 ); + update_user_meta( $user_id, 'slash_test_2', $this->slash_4 ); + update_user_meta( $user_id, 'slash_test_3', $this->slash_6 ); - $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $id, 'slash_test_1', true ) ); - $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $id, 'slash_test_2', true ) ); - $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $user_id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $user_id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $user_id, 'slash_test_3', true ) ); } } diff --git a/tests/phpunit/tests/post/slashes.php b/tests/phpunit/tests/post/slashes.php index bc8b1d8dc002..25a024057679 100644 --- a/tests/phpunit/tests/post/slashes.php +++ b/tests/phpunit/tests/post/slashes.php @@ -32,10 +32,10 @@ function setUp() { * Tests the controller function that expects slashed data. */ function test_edit_post() { - $id = self::factory()->post->create(); + $post_id = self::factory()->post->create(); $_POST = array(); - $_POST['post_ID'] = $id; + $_POST['post_ID'] = $post_id; $_POST['post_title'] = $this->slash_1; $_POST['content'] = $this->slash_5; $_POST['excerpt'] = $this->slash_7; @@ -50,7 +50,7 @@ function test_edit_post() { $this->assertSame( $this->slash_7, $post->post_excerpt ); $_POST = array(); - $_POST['post_ID'] = $id; + $_POST['post_ID'] = $post_id; $_POST['post_title'] = $this->slash_2; $_POST['content'] = $this->slash_4; $_POST['excerpt'] = $this->slash_6; @@ -69,7 +69,7 @@ function test_edit_post() { * Tests the model function that expects slashed data. */ function test_wp_insert_post() { - $id = wp_insert_post( + $post_id = wp_insert_post( array( 'post_status' => 'publish', 'post_title' => $this->slash_1, @@ -79,13 +79,13 @@ function test_wp_insert_post() { 'slashed' => false, ) ); - $post = get_post( $id ); + $post = get_post( $post_id ); $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title ); $this->assertSame( wp_unslash( $this->slash_3 ), $post->post_content ); $this->assertSame( wp_unslash( $this->slash_5 ), $post->post_excerpt ); - $id = wp_insert_post( + $post_id = wp_insert_post( array( 'post_status' => 'publish', 'post_title' => $this->slash_2, @@ -94,7 +94,7 @@ function test_wp_insert_post() { 'post_type' => 'post', ) ); - $post = get_post( $id ); + $post = get_post( $post_id ); $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title ); $this->assertSame( wp_unslash( $this->slash_4 ), $post->post_content ); @@ -105,17 +105,17 @@ function test_wp_insert_post() { * Tests the model function that expects slashed data. */ function test_wp_update_post() { - $id = self::factory()->post->create(); + $post_id = self::factory()->post->create(); wp_update_post( array( - 'ID' => $id, + 'ID' => $post_id, 'post_title' => $this->slash_1, 'post_content' => $this->slash_3, 'post_excerpt' => $this->slash_5, ) ); - $post = get_post( $id ); + $post = get_post( $post_id ); $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title ); $this->assertSame( wp_unslash( $this->slash_3 ), $post->post_content ); @@ -123,13 +123,13 @@ function test_wp_update_post() { wp_update_post( array( - 'ID' => $id, + 'ID' => $post_id, 'post_title' => $this->slash_2, 'post_content' => $this->slash_4, 'post_excerpt' => $this->slash_6, ) ); - $post = get_post( $id ); + $post = get_post( $post_id ); $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title ); $this->assertSame( wp_unslash( $this->slash_4 ), $post->post_content ); @@ -140,26 +140,26 @@ function test_wp_update_post() { * @ticket 27550 */ function test_wp_trash_untrash() { - $post = array( + $post = array( 'post_title' => $this->slash_1, 'post_content' => $this->slash_3, 'post_excerpt' => $this->slash_5, ); - $id = wp_insert_post( wp_slash( $post ) ); + $post_id = wp_insert_post( wp_slash( $post ) ); - $trashed = wp_trash_post( $id ); + $trashed = wp_trash_post( $post_id ); $this->assertNotEmpty( $trashed ); - $post = get_post( $id ); + $post = get_post( $post_id ); $this->assertSame( $this->slash_1, $post->post_title ); $this->assertSame( $this->slash_3, $post->post_content ); $this->assertSame( $this->slash_5, $post->post_excerpt ); - $untrashed = wp_untrash_post( $id ); + $untrashed = wp_untrash_post( $post_id ); $this->assertNotEmpty( $untrashed ); - $post = get_post( $id ); + $post = get_post( $post_id ); $this->assertSame( $this->slash_1, $post->post_title ); $this->assertSame( $this->slash_3, $post->post_content ); diff --git a/tests/phpunit/tests/term/slashes.php b/tests/phpunit/tests/term/slashes.php index 967e4834bdb5..bc114c16d9d6 100644 --- a/tests/phpunit/tests/term/slashes.php +++ b/tests/phpunit/tests/term/slashes.php @@ -82,14 +82,14 @@ function test_wp_update_term() { 'post_tag', ); foreach ( $taxonomies as $taxonomy ) { - $id = self::factory()->term->create( + $term_id = self::factory()->term->create( array( 'taxonomy' => $taxonomy, ) ); $update = wp_update_term( - $id, + $term_id, $taxonomy, array( 'name' => $this->slash_1, @@ -97,31 +97,31 @@ function test_wp_update_term() { ) ); - $term = get_term( $id, $taxonomy ); + $term = get_term( $term_id, $taxonomy ); $this->assertSame( wp_unslash( $this->slash_1 ), $term->name ); $this->assertSame( wp_unslash( $this->slash_3 ), $term->description ); $update = wp_update_term( - $id, + $term_id, $taxonomy, array( 'name' => $this->slash_3, 'description' => $this->slash_5, ) ); - $term = get_term( $id, $taxonomy ); + $term = get_term( $term_id, $taxonomy ); $this->assertSame( wp_unslash( $this->slash_3 ), $term->name ); $this->assertSame( wp_unslash( $this->slash_5 ), $term->description ); $update = wp_update_term( - $id, + $term_id, $taxonomy, array( 'name' => $this->slash_2, 'description' => $this->slash_4, ) ); - $term = get_term( $id, $taxonomy ); + $term = get_term( $term_id, $taxonomy ); $this->assertSame( wp_unslash( $this->slash_2 ), $term->name ); $this->assertSame( wp_unslash( $this->slash_4 ), $term->description ); } diff --git a/tests/phpunit/tests/user/slashes.php b/tests/phpunit/tests/user/slashes.php index 87def324af30..ee54b5efc3c7 100644 --- a/tests/phpunit/tests/user/slashes.php +++ b/tests/phpunit/tests/user/slashes.php @@ -48,8 +48,8 @@ function test_add_user() { $_POST = add_magic_quotes( $_POST ); // The add_user() function will strip slashes. - $id = add_user(); - $user = get_user_to_edit( $id ); + $user_id = add_user(); + $user = get_user_to_edit( $user_id ); $this->assertSame( $this->slash_1, $user->first_name ); $this->assertSame( $this->slash_3, $user->last_name ); @@ -73,8 +73,8 @@ function test_add_user() { $_POST = add_magic_quotes( $_POST ); // The add_user() function will strip slashes. - $id = add_user(); - $user = get_user_to_edit( $id ); + $user_id = add_user(); + $user = get_user_to_edit( $user_id ); $this->assertSame( $this->slash_2, $user->first_name ); $this->assertSame( $this->slash_4, $user->last_name ); @@ -87,7 +87,7 @@ function test_add_user() { * Tests the controller function that expects slashed data. */ function test_edit_user() { - $id = self::factory()->user->create(); + $user_id = self::factory()->user->create(); $_POST = array(); $_GET = array(); @@ -102,8 +102,8 @@ function test_edit_user() { $_POST = add_magic_quotes( $_POST ); // The edit_user() function will strip slashes. - $id = edit_user( $id ); - $user = get_user_to_edit( $id ); + $user_id = edit_user( $user_id ); + $user = get_user_to_edit( $user_id ); $this->assertSame( $this->slash_1, $user->first_name ); $this->assertSame( $this->slash_3, $user->last_name ); @@ -124,8 +124,8 @@ function test_edit_user() { $_POST = add_magic_quotes( $_POST ); // The edit_user() function will strip slashes. - $id = edit_user( $id ); - $user = get_user_to_edit( $id ); + $user_id = edit_user( $user_id ); + $user = get_user_to_edit( $user_id ); $this->assertSame( $this->slash_2, $user->first_name ); $this->assertSame( $this->slash_4, $user->last_name ); @@ -138,7 +138,7 @@ function test_edit_user() { * Tests the model function that expects slashed data. */ function test_wp_insert_user() { - $id = wp_insert_user( + $user_id = wp_insert_user( array( 'user_login' => 'slash_example_user_3', 'role' => 'subscriber', @@ -151,7 +151,7 @@ function test_wp_insert_user() { 'user_pass' => '', ) ); - $user = get_user_to_edit( $id ); + $user = get_user_to_edit( $user_id ); $this->assertSame( wp_unslash( $this->slash_1 ), $user->first_name ); $this->assertSame( wp_unslash( $this->slash_3 ), $user->last_name ); @@ -159,7 +159,7 @@ function test_wp_insert_user() { $this->assertSame( wp_unslash( $this->slash_7 ), $user->display_name ); $this->assertSame( wp_unslash( $this->slash_3 ), $user->description ); - $id = wp_insert_user( + $user_id = wp_insert_user( array( 'user_login' => 'slash_example_user_4', 'role' => 'subscriber', @@ -172,7 +172,7 @@ function test_wp_insert_user() { 'user_pass' => '', ) ); - $user = get_user_to_edit( $id ); + $user = get_user_to_edit( $user_id ); $this->assertSame( wp_unslash( $this->slash_2 ), $user->first_name ); $this->assertSame( wp_unslash( $this->slash_4 ), $user->last_name ); @@ -185,10 +185,10 @@ function test_wp_insert_user() { * Tests the model function that expects slashed data. */ function test_wp_update_user() { - $id = self::factory()->user->create(); - $id = wp_update_user( + $user_id = self::factory()->user->create(); + $user_id = wp_update_user( array( - 'ID' => $id, + 'ID' => $user_id, 'role' => 'subscriber', 'first_name' => $this->slash_1, 'last_name' => $this->slash_3, @@ -197,7 +197,7 @@ function test_wp_update_user() { 'description' => $this->slash_3, ) ); - $user = get_user_to_edit( $id ); + $user = get_user_to_edit( $user_id ); $this->assertSame( wp_unslash( $this->slash_1 ), $user->first_name ); $this->assertSame( wp_unslash( $this->slash_3 ), $user->last_name ); @@ -205,9 +205,9 @@ function test_wp_update_user() { $this->assertSame( wp_unslash( $this->slash_7 ), $user->display_name ); $this->assertSame( wp_unslash( $this->slash_3 ), $user->description ); - $id = wp_update_user( + $user_id = wp_update_user( array( - 'ID' => $id, + 'ID' => $user_id, 'role' => 'subscriber', 'first_name' => $this->slash_2, 'last_name' => $this->slash_4, @@ -216,7 +216,7 @@ function test_wp_update_user() { 'description' => $this->slash_4, ) ); - $user = get_user_to_edit( $id ); + $user = get_user_to_edit( $user_id ); $this->assertSame( wp_unslash( $this->slash_2 ), $user->first_name ); $this->assertSame( wp_unslash( $this->slash_4 ), $user->last_name );